Reputation: 878
I want to style my list like this:
^^ you see here the first is bold, second is normal, third is bold, and so on.
I want to make the same thing dynamically on my list.
Upvotes: 12
Views: 14908
Reputation: 15802
Something like this should do the job
ul.zebra li:nth-child(odd),
ol.zebra li:nth-child(odd)
{
font-weight: bold;
}
And your markup would be
<ul class="zebra">
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ul>
or
<ol class="zebra">
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ol>
ul.zebra li:nth-child(odd),
ol.zebra li:nth-child(odd)
{
font-weight: bold;
}
<ul class="zebra">
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ul>
<ol class="zebra">
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ol>
Upvotes: 1
Reputation: 5958
li:nth-child(odd) { font-weight:bold }
li:nth-child(even) { font-weight:normal }
Upvotes: 0
Reputation: 24832
ol li
{
font-weight:normal
}
ol li:nth-child(odd){
font-weight:bold;
}
Upvotes: 0
Reputation: 3076
Use css3 selector nth-child
:
ol>li:nth-child(odd){
font-weight:bold;
}
Here: http://jsfiddle.net/FwTBU/
Upvotes: 30