CSS ul li:避免双边界

前端之家收集整理的这篇文章主要介绍了CSS ul li:避免双边界前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个UL
border: 1px solid grey;

它包含几个LI

border-bottom: 1px dotted grey;

保持物品在视觉上分开.但是现在最后一个李有虚线边框和UL固体边框!这看起来很讨厌.我该如何避免?有没有办法把边界放在李氏而不是之后呢?

解决方法

CSS3选择器可以定位:first-child或:last-child,如下所示:
ul {
    border: 1px solid grey;
}
li {
    border-bottom: 1px dotted grey;
}
li:last-child {
    border:none;
}

一个工作实例:http://api.fatherstorm.com/test/4165384.php

原文链接:https://www.f2er.com/css/214570.html

猜你在找的CSS相关文章