使用css选择倒数第二个元素 [英] Select second last element with css
本文介绍了使用css选择倒数第二个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经知道:last-child。但是有办法选择div:
< div id =container>
< div> a< / div>
< div> b< / div>
< div> SELECT THIS< / div> <! - THIS - >
< div> c< / div>
< / div>
注意:没有jQuery,只有CSS
:nth-last-child(2)
请参阅: http://webdesign.about.com/od/styleproperties/p/nth-last-child.htm
第n个最后一个子浏览器支持:
- Chrome 2
- Firefox 3.5
- Opera 9.5,10
- Safari 3.1,4
- Internet Explorer 9
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>
NOTE: without jQuery, only with CSS
解决方案
In CSS3 you have:
:nth-last-child(2)
See: http://webdesign.about.com/od/styleproperties/p/nth-last-child.htm
nth-last-child Browser Support:
- Chrome 2
- Firefox 3.5
- Opera 9.5, 10
- Safari 3.1, 4
- Internet Explorer 9
这篇关于使用css选择倒数第二个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文