css选择符有:1、通配选择符“*”;2、id选择符;3、类选择符;4、标签选择符;5、相邻选择符“E+F”;6、子选择器“E>F”;7、后代选择符“E F”;8、伪类和伪元素选择符,例如“:first”;9、属性选择符。

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。 css选择符(选择器)是用来规定css样式用于哪一个或哪一些dom元素的一种规范。 每一条css样式定义由两部分组成,形式如下:选择器{样式} 在{}之前的部分就是“选择器”。 “选择器”指明了{}中的“样式”的作用对象(dom对象),也就是“样式”作用于网页中的哪些元素。 css选择符(选择器)有哪些? 1、通配选择符( * ):匹配任意元素。 2、id选择符( # myid):匹配 ID 等于“myid”的任意元素 。 3、类选择符(.myclassname):匹配 class 等于“myclassname”的任意元素. 4、标签选择符(div, h1, p):选择指定元素名称的所有元素。 5、相邻选择符(E + F):用于选择(不是内部)指定的第一个元素之后紧跟的元素。 6、子选择符(E > F):用于选取带有特定父元素的元素,例ul > li,选择所有父级是 <ul> 元素的每个 <li> 元素。(学习视频分享:css视频教程) 7、后代选择符(E F):用于选取元素内部的元素。 8、伪类和伪元素选择符:用于向某些选择器添加特殊的效果。 | :active | :any-link | :blank | :checked | :current | :default | | :defined | :dir() | :disabled | :drop | :empty | :enabled | | :first | :first-child | :first-of-type | :fullscreen | :future | :focus | | :focus-visible | :focus-within | :has() | :host | :host() | :host-context() | | :hover | :indeterminate | :in-range:invalid | :is() | :lang() | :last-child | | :last-of-type | :left | :link | :local-link | :not() | :nth-child() | | :nth-col() | :nth-last-child() | :nth-last-col() | :nth-last-of-type() | :nth-of-type() | :only-child | | :only-of-type | :optional | :out-of-range | :past | :placeholder-shown | :read-only | | :read-write | :required | :right | :root | :scope | :target | | :target-within | :user-invalid | :valid | :visited | :where() |
|
9、属性选择符:选择带有特定属性的元素。
[attribute]:用于选取带有指定属性的元素。 [attribute=value]:用于选取带有指定属性和值的元素。 [attribute~=value]:用于选取属性值中包含指定词汇的元素。 [attribute|=value]:用于选取带有以指定值开头的属性值的元素,该值必须是整个单词。 [attribute^=value]:匹配属性值以指定值开头的每个元素。 [attribute$=value]:匹配属性值以指定值结尾的每个元素。 [attribute*=value]:匹配属性值中包含指定值的每个元素。
更多编程相关知识,请访问:编程入门!! 以上就是css的选择符有哪些的详细内容,更多请关注模板之家(www.mb5.com.cn)其它相关文章! |