Reputation: 2011
<article class="tweet-inner">
<div class="text-wrapper">
<div class="tweet">
<div class="text">
<p>Coming down! Time for Croation BBQ </p>
</div>
<p class="last">
<span class="pull-right">
<small> Hello this is first text </small>
<small> Hello this is second text </small>
</span>
</p>
</div>
</div>
</article>
I have the following repeating html structure.
As of now, I want to provide alternate rows with different background. The element which I want to color is class=text
I do the following in my css -
.tweet-inner .tweet .text-wrapper .text:nth-child(even) {
background-color: #FF0000;
}
This does not work, I also tried -
.text:nth-child(even) {
background-color: #FF0000;
}
This is what works -
article.text:nth-child(even) {
background-color: #FF0000;
}
But I want the .text
to be alternately colored, not the entire article.
This also does not work.
The fiddle is http://jsfiddle.net/LKqvz/. Please let me know.
Upvotes: 0
Views: 76
Reputation: 6871
try this:
article:nth-child(even) .tweet .text {
background-color: #FF0000;
}
Upvotes: 0
Reputation: 16719
It should be:
article:nth-child(even) .text{
...
}
Because you have multiple article
elements with a single .text
DIV (your attempts select the nth .text
child from article
)
Upvotes: 1