奋起直追,fighting
我在这里!

常用的样式选择器有:ID选择器,关联选择器,HTML选择器,类选择器,组合选择器,伪元素选择器等等

1、HTML(标签)选择器

如:
p{text-indent :3em }
h1{color:red}

2、类选择器

如:
p.d {background-color:#008888;}
p.e {background-color :#008800 ;}

<p class="e">first</p>
<p class="d">first</p>
如:
.note{font-size : small} /*为note的类可以被用于任何元素*/

3、ID选择器(#id名)
id属性指定某个单一元素,id选择器用来对这个单一元素定义单独的样式。
如:
#main{text-indent:3em}

<p id = "main">文本缩进3em</p>
4、关联(后代)选择器
如:
table a{color :red} /*只有表格中的<a>改变样式*/
5、组合选择器
如:
h1,h2,h3,h4{color = "red"}

6、伪元素选择器
HTML标签:伪元素{属性:值}
如:
a:link{color :red}
a:hover{color:blue}

7、属性选择器
如:
x[title]:
a[title]{color :green ;}

x[title = ""]:
a[title = "face1"]{color :#008800 ;}

8、相邻选择器(x + y )或(x ~ y )
如:
ul + p{
color :red
}   /*匹配ul后的第一个p*/
如:
ul ~ p {
color :red
}   /*匹配所有ul相邻的p*/


9、子选择器(x>y)
匹配x下的子元素y

 

 


 

posted on 2013-06-08 20:20  Thomas_C  阅读(85)  评论(0)    收藏  举报