CSS 子元素选择器

所有选择器参考手册:http://www.w3school.com.cn/cssref/css_selectors.asp

1)子元素选择器

参考链接:http://www.w3school.com.cn/cssref/selector_nth-child.asp

p:nth-child(2)
{
background:#ff0000;
}
选择所有的p元素 的 父元素 的 第二个子元素,不论类型

  

2)子元素选择器,带类型

p:nth-of-type(2)#选择元素p 的 父元素 的 第二个子元素,不论类型
{ background:#ff0000; }

 

3)还能这样选择

header #search input[type="text"] {

  

posted @ 2019-06-15 22:07  凌晨四点的蓝  阅读(305)  评论(0编辑  收藏  举报