码迷,mamicode.com
首页 > 其他好文 > 详细

nth-child(1) 和 和 first-of-type的区别

时间:2017-10-31 14:23:58      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:col   一个   child   first   标签   -o   code   nbsp   style   

nth-child() 是指该元素处在父级元素下不论标签的类型下排第几个

 

<section>
    <div>我是一个普通的div标签</div>         //第一个div儿子  表示 p:first-child      div:first-child或者 div:first-of-type  
    <p>我是第1个p标签</p>                   //第一个P儿子    表示 p:first-of-type    div:nth-child(2) 
    <p>我是第2个p标签</p>  <!-- 希望这个变红 -->  
    <div>我是一个普通的div标签</div> 
</section>

 

first-of-type 是指该元素处在父级元素下同种标签的第几个 

nth-child(1) 和 和 first-of-type的区别

标签:col   一个   child   first   标签   -o   code   nbsp   style   

原文地址:http://www.cnblogs.com/tenro/p/7760823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!