css选择符的类型

Posted on : 31-07-2011 | By : kim | In : 计数, 读书笔记

0

1、ID选择符   #top{ margin-left:20px; }

2、类选择符   .top{ padding-left:20px; }

3、类型选择符 a{ color:#f00; }

4、相邻兄弟选择符 h1 + #top{ margin-top:20px;  }//匹配前面有h1的top元素

5、子选择符 #top > li{ height:20px; }

6、后代选择符 #top a {color:#f60;}

7、通配选择符 *{ font-family:Arial; }

8、属性选择符 [href="#index"]{ font-style:italic; }// =号,全等;判断属性是否存在[href];[title~="index"],等于用空格分隔的属性值列表中的任意一个;[lang|=en],等于属性值用连字符-分隔开的属性值列表中的第一个。

9、伪类和伪元素 a:hover{ color:#f60; },其他的伪类还包括::first-child、:link、:visited、:active、:focus、:lang;伪元素包括::first-line、:first-letter、:before和:after。

Write a comment