Vicheanak Vicheanak - 11 months ago 61
CSS Question

How to get the last Element of CSS?

<ul class="blog-year">
<li><a href="">2016</a><span class="year-seperator">|</span></li>
<li><a href="">2015</a><span class="year-seperator">|</span></li>
<li><a href="">2014</a><span class="year-seperator">|</span></li>
<li><a href="">2013</a><span class="year-seperator">|</span></li>

in my css:

display: none;

Then all the separator disappear. Why? How can I get the last element of that class? Or How can I hide it?

Answer Source

Because they are all at last of li. It's the last li element not last span element. It should look like this:

li:last-child .year-seperator {
    display: none;