css选择器有哪些
1.Id选择器(#id)
2.类选择器(.classname)
3.标签选择器(div h1 p)
4.相邻选择器(h1+p)
5.子选择器(ul<li)
6.后代选择器(li a)
7.通配符选择器(*)
8属性选择器(a[rel=“ex”)
9.伪类选择器 (a:hover)
可继承:font-sizefont-familycolor,ULLIDLDDDT;
不可继承:borderpaddingmarginwidthheight;*
优先级就近原则,样式定义最近者为准;*载入样式以最后载入的定位为准;优先级为:!important>id>class>tagimportant比内联优先级高
CSS3新增伪类举例:
p:first-of-type选择属于其父元素的首个
元素的每个
元素。
p:last-of-type选择属于其父元素的最后
元素的每个
元素。
p:only-of-type选择属于其父元素唯一的
元素的每个
元素。
p:only-child选择属于其父元素的唯一子元素的每个
元素。
p:nth-child(2)选择属于其父元素的第二个子元素的每个
元素。
:enabled、:disabled控制表单控件的禁用状态。
:checked,单选框或复选框被选中。