2
Hello, I’m having a problem. I’m trying to make each post have a different background color. I tried using this code below in css but it leaves all posts one color.
div.postagem > div:nth-child(1) {
background: #edc333;
}
div.postagem > div:nth-child(2) {
background: #000;
}
div.postagem > div:nth-child(3){
background: #3e4095;
}
This is the code I have in my post area:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="col-md-4"><div class="postagem">
<div class="postagem-imagem">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'miniatura' );
} ?></div>
<div class="titulo"> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></div>
</div></div>
<?php endwhile?>
<?php else: ?>
<h2>Nada Encontrado</h2><?php endif; ?>
This is the code I have in css.
.postagem {
height: 340px;
overflow: hidden;
}
.postagem img {
opacity: 0.2;
filter: grayscale(100%);
-webkit-filter: grayscale(100%);
}
.postagem-imagem img {
opacity: 0.3;
}
.titulo {
font-size: 17.473px;
font-family: "Arial";
color: rgb(254, 255, 254);
font-weight: 900;
padding: 20px;
text-transform: uppercase;
line-height: 1.2;
text-align: left;
position: absolute;
z-index: 111;
top: 45px;
}
.titulo a {
color: #fff;
}
Can anyone help? Thank you in advance!
your CSS is being loaded after the Theme css?
– Luís Almeida
@Luísalmeida My Theme only has 1 css that is where everything is.
– Lia
as the css name indicates, the styles work by Cascade... check if the last class to be applied is yours...
– Luís Almeida