css3选择器

来源:互联网 发布:手机数据恢复免费软件 编辑:程序博客网 时间:2024/05/29 11:20


属性选择器:
div[data-info]  选择有这个属性的
Div[data-info="1"] 完全匹配
div[data-info ^= "h"] 匹配开头
div[data-info $= "h"]匹配结尾
div[data-info ~= "h"]匹配空格
div[data-info |= "h"]匹配短横、开头
div[data-info *= "h"]匹配任意
Css3选择器:
Div:first-child{}第一个儿子
Div:last-child{}最后一个儿子
Div:nth-child(n) 选择din儿子
Div:nth-child(2n+3)从第三个开始每两个选一个
Div:nth-last-child(2n+3) 倒数
//类型
Div:first-of-type{} 第一个div类型的
Div:last-of-type{} 最后一个div类型的
Div:nth-of-type(n)第3个div类型的
DIV:nth-of-type(2n+3)选出div类型的从第三个开始,每两个选一个
Div:nth-last-of-type(2n+3)倒数
//关系
Div>p 所有的后代p
Div+p 下一个亲P
Div~p 后面的所有p
//伪类
:hover
:focus 得到焦点
:enabled 有效的
:disabled 无效的
:empty 空标签
//伪元素
::before 
::after 
//一定要有content;他们是行内的元素;他们是子集元素

::selection 反选的内容
::first-line 首行
::first-letter 首字

原创粉丝点击