html - 删除最后一个 li 边框

标签 html css

我对 css 不是很了解,如何从 css 中的最后一个 li 元素中删除 border-bottom。

ul li{
   border-bottom: 1px solid blue;
}

最佳答案

您可以使用:last-child伪类:

ul li:last-child {
   border-bottom: 0;
}

这只适用于 IE9+。作为解决方法,您可以为列表项提供顶部边框并覆盖 :first-child 的值。 :

ul li {
   border-top: 1px solid blue;
}

ul li:first-child {
   border-top: 0;
}

关于html - 删除最后一个 li 边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29587152/

相关文章:

javascript - ClearFix 在 AngularJs 中不起作用

html - Internet Explorer 中的 Div 相对定位问题

jquery - PrimeNG - 如何在 p-tabView 组件中动态添加和删除 p-tabPanel

javascript - CSS媒体查询,如果高度大于500px,如何在div下添加阴影?

javascript - 用于动态元素和 ajax 的 jQuery 验证插件

javascript - document.getElementbyId - 一次获取多个 ID?

javascript - 一次导入javascript库

javascript - HighCharts - 在值为 0 或 null 的列上显示工具提示

html - 每个按钮上带有自定义图像或图标的 CSS 菜单

css - 是否可以用 css 实现斜边?