不申请:最后一个孩子到文章

Mig*_*ura 4 html css css-selectors

我有以下标记

<div>
  <article>article 1</article>
  <article>article 2</article>
  <article>article 3</article>
  <article>article 4</article>
  <ul class="pagination">
    <li>Page 1</li>
    <li>Page 2</li>
  </ul>
</div>
Run Code Online (Sandbox Code Playgroud)

我尝试对每篇文章应用底部边框,但不对最后一篇应用:

article:not(:last-child) {
  border-bottom: 8px solid #404040;
}
Run Code Online (Sandbox Code Playgroud)

但是有了这个,我在上一篇文章中得到了一个边框.

如果我删除UL,那么上一篇文章没有边框.

这很奇怪,因为我只是将风格应用于文章.

我怎么解决这个问题?

谢谢你,米格尔

Hir*_*ral 5

它应该是last-of-type代替last-child.

article:not(:last-of-type) {
  border-bottom: 8px solid #404040;
}
Run Code Online (Sandbox Code Playgroud)

DEMO在这里.