How to get the last Element of CSS?

0

Issue

.year-seperator:last-of-type {
    display: none;
}
<ul class="blog-year">  
    <li><a href="http://my.link">2016</a><span class="year-seperator">|</span></li>
    <li><a href="http://my.link">2015</a><span class="year-seperator">|</span></li>
    <li><a href="http://my.link">2014</a><span class="year-seperator">|</span></li>
    <li><a href="http://my.link">2013</a><span class="year-seperator">|</span></li>
</ul>

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

Solution

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;
}

Answered By – Quy Truong

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More