赞
踩
html零基础必看——html入门,编程就是如此简单
如:
a[target]{color: red; }
选择a标签里面 拥有target属性的标签 然后加个红色的字体样式
如:
a[target$="k"]{ color: green; }
找到a标签 拥有target属性的标签,并且是以k结尾的属性值
如:
a[href^="h"]{color: pink; }
找到a标签 拥有href属性的标签 并且是以h为开头的属性值
如:
a[target*="se"]{ color: skyblue; }
找到a标签 拥有target属性的标签 并且包含了se这两个字符的属性值
元素在特定状态下发生样式的改变
鼠标状态:
:hover
鼠标悬停状态 常用:active
鼠标点击状态
仅限a标签使用的:
link
未被访问的链接(仅限a标签使用):visited
已被访问过的的链接(仅限a标签使用)
仅限input表单控件状态下:
5.:focus
表单输入框获得焦点状态下(先要清除默认样式)
6.:checked
表单被勾选(单选/多选)的状态下
结构 :子元素选择器 :nth-child(n)
ul>li:nth-child(3)
ul>li:first-child
ul>li:last-child
ul>li:nth-child(2n-1)或 ul>li:nth-child(odd)
ul>li:nth-child(2n)或 ul>li:nth-child(even )
li:nth-child(1),li:nth-child(4)
ul>li:nth-child(n+3)
p::before{content:"Hello World!"}
p::after {content:"Hello World!"}
::afte
常用来清除浮动,前面第十章中浮动中的高度塌陷问题有讲到content
样式,上述两个伪元素才会生效。content
除了写文字之外,还可以用url指定一张图片等其他写法。!important > 行内样式 > id > 子代 > class | 属性 | 伪类 |
伪元素 > 标签 | +(相邻) | ~ (关联)| > * 通配符
上述是小编为大家整理的CSS一些比较重要的选择器,进行分类归纳。参考多方资料加上自己的理解整理出来的,或有不确之处和疏漏的地方,还望各位大佬能够不吝赐教,加以斧正,小编在此先行谢过了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。