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"] {

  

转载于:https://www.cnblogs.com/Gaoqiking/p/11029055.html

猜你喜欢

转载自blog.csdn.net/weixin_34406061/article/details/93256750