Css3 last-child not working as expected

I have speaker lists generated dynamically. After each member, I show li, which displays the VS inside it. However, the most recent ul li in the div match should not be visible. Any ideas how I can do this? 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>
+3
source share
2 answers

The class pseudo-class :last-childshould be applied to ul, but not libecause you want the VS text of the last ullist to be hidden. Applying the pseudo-class to li, you apply styles to the last li one ul , which is wrong.

class li VS, .

<li style="">VS</li>

<li class="vs">VS</li>

:last-child:

.match ul:last-child li.vs {
    display: none;
}
+10

, IE . , , 100%.

+4

Source: https://habr.com/ru/post/1766573/


All Articles