I have match listings dynamically generated. After each member I display a li that displays VS within it. However the very last ul li in the div match shouldnt be visible. Any ideas how I can do that?
HTML
<style>
.match {
}
.match ul {
}
.match ul li {
float: left;
margin-right: 50px;
}
.match ul li:last-child {
display: none;
}
</style>
<div class="content">
<div class="match">
<ul>
<li><a href="/wade-barrett/member">Wade Barrett</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/shaemus/member">Shaemus</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/randy-orton/member">Randy Orton</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/john-cena/member">John Cena</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/edge/member">Edge</a></li>
<li style="">VS</li>
</ul>
<ul>
<li><a href="/chris-jericho/member">Chris Jericho</a></li>
<li style="">VS</li>
</ul>
<p class="clear"></p>
</div>
</div>
The
:last-childpseudo-class should apply to theul, notli, because you want VS text of the lastulof the list to be hidden. By applying the pseudo-class toli, you’re applying styles to the lastliof everyul, which is incorrect.You should also apply a
classattribute to thelielements with the VS text so that it’s more convenient to match with a class selector.Change
to
And use this instead of your current
:last-childselector: