Select second last element with css(用css选择倒数第二个元素)
问题描述
我已经知道 :last-child.但是有没有办法选择div:
I already know of :last-child. But is there a way to select the div:
<div id="container">
<div>a</div>
<div>b</div>
<div>SELECT THIS</div> <!-- THIS -->
<div>c</div>
</div>
注意:没有 jQuery,只有 CSS
NOTE: without jQuery, only with CSS
推荐答案
在 CSS3 中你有:
In CSS3 you have:
:nth-last-child(2)
参见:https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-last-child
nth-last-child 浏览器支持:
- Chrome 2
- 火狐 3.5
- Opera 9.5、10
- Safari 3.1、4
- Internet Explorer 9
这篇关于用css选择倒数第二个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!