网站制作学习网DIV+CSS→正文:CSS3选择器(四)结构性伪类6
字体:

CSS3选择器(四)结构性伪类6

DIV+CSS 2010/12/15 14:43:33  点击:不统计

转载%77%77%77请%2E%66%6F%72%61%73%70%2E%63%6E注明
第十八节:CSS3选择器之:结构性伪类 E:last-child

语法
E:last-child : {attribute}
相关伪类:E:root | E:nth-child | E:nth-last-child | E:nth-of-type | E:nth-last-of-type | E:first-of-type | E:only-child | E:only-of-type | E:empty

说明
匹配父元素中最后一个E元素

兼容性
Firefox3.0,Firefox3.5,Chrome1.0,Chrome2.0,Opera9.63,Safari3.1,Safari 4Public beta

代码示例
<style type="text/css">
p:last-child {color:#FF0000;}
</style>
<div style="width:733px; border: 1px solid #666; padding:5px;">
    <p>匹配父元素中的第n个子元素E,这里的字的颜色是黑色的</p>
    <p>匹配父元素中的第n个子元素E,这里的字的颜色是黑色的</p>
    <p>匹配父元素中的第n个子元素E,这里的字的颜色是黑色的</p>
    <p>匹配父元素中的第n个子元素E,这里的字的颜色被设置成了红色</p>
</div>

原载于:本文原载于www.forasp.cn

·上一篇:CSS3选择器(四)结构性伪类5 >>    ·下一篇:CSS3选择器(四)结构性伪类7 >>
推荐文章
最新文章