码迷,mamicode.com
首页 > Web开发 > 详细

CSS选择器

时间:2018-08-19 00:51:52      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:bsp   基础   通用   元素   text   动态   after   lin   before   

一、基础选择器

1、元素选择器

例:h1{color:red}

2、类选择器

例:.text{color:red}

3、ID选择器

例:#code{color:red}

4、通配符选择器(*)

例:*{color:red}

5、并集选择器

例:h1,h2,h3,.text,#code{color:red}

二、层次选择器

1、子级选择器

例:div>em{font-size:18px}

2、后代选择器

例:div  em{

  font-size:18px;

}

3、兄弟选择器

例:div+em{

  font-size:18px;

}

4、通用选择器

div~em{

  font-size:18px;

}

三、伪类选择器

1、动态伪类选择器

link  visited  hover  active

2、结构伪类选择器

(1):first-child

(2):last-child

(3):nth-child(n)

(4):nth-of-type

(5):not(:nth-child(n))

(6):only-child

(7):empty

四、伪元素选择器

1、选中第一行

:firstline

2、选中第一个字

:first-letter

3、在标签前面加内容

::before

4、在标签后面加内容

::after

CSS选择器

标签:bsp   基础   通用   元素   text   动态   after   lin   before   

原文地址:https://www.cnblogs.com/smuwgeg/p/9499063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!