Using the last-child selector(使用最后一个子选择器)
问题描述
我的目标是在最后一个 li
上应用 CSS,但它没有这样做.
My goal is to apply the CSS on the last li
, but it doesn't do that.
#refundReasonMenu #nav li:last-child {
border-bottom: 1px solid #b5b5b5;
}
<div id="refundReasonMenu">
<ul id="nav">
<li><a id="abc" href="#">abcde</a></li>
<li><a id="def" href="#">xyz</a></li>
</ul>
</div>
如何只选择最后一个孩子?
推荐答案
:last-child
伪类仍然不能可靠地跨浏览器使用.特别是,Internet Explorer 版本 <9、Safari <3.2 肯定 不支持,虽然 Internet Explorer 7 和 Safari3.2 做支持:first-child
,奇怪.
The :last-child
pseudoclass still cannot be reliably used across browsers. In particular, Internet Explorer versions < 9, and Safari < 3.2 definitely don't support it, although Internet Explorer 7 and Safari 3.2 do support :first-child
, curiously.
最好的办法是显式地为该项目添加一个 last-child
(或类似的)类,并改为应用 li.last-child
.
Your best bet is to explicitly add a last-child
(or similar) class to that item, and apply li.last-child
instead.
这篇关于使用最后一个子选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用最后一个子选择器


基础教程推荐
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01