css 元素选择器
子元素选择器
h1 > strong {color:red;} //这个规则会把第一个 h1 下面的两个 strong 元素变为红色,但是第二个 h1 中的 strong 不受影响: <h1>This is <strong>very</strong> <strong>very</strong> important.</h1> <h1>This is <em>really <strong>very</strong></em> important.</h1>
后代选择器(descendant selector)又称为包含选择器
h1 em {color:red;} //上面这个规则会把作为 h1 元素后代的 em 元素的文本变为 红色。其他 em 文本(如段落或块引用中的 em)则不会被这个规则选中: <h1>This is a <em>important</em> heading</h1> <p>This is a <em>important</em> paragraph.</p>
通用兄弟选择器
位置无须紧邻,只须同层级,A~B 选择A元素之后所有同层级B元素。
p ~ span { color: red; } <span>This is not red.</span> <p>Here is a paragraph.</p> <code>Here is some code.</code> <span>And here is a span.</span> //This is not red. Here is a paragraph. Here is some code.And here is a span.
相邻兄弟选择器
li:first-of-type + li { color: red; } <ul> <li>One</li> <li>Two!</li> <li>Three</li> </ul> //One Two! Three
本人是一个技术爱好者
1.但是每个技术爱好者都是从萌新开始的
2.我所有的博文都是我各方资料查阅(看的比较乱比较杂,因为有些是群里讨论等等来源,无法辨别出处,所以我的文章都是没有写明出处,都是我个人消化后整理,)
3.但是没有经过我实践的我一般会标注
4.希望大家共同交流共同进步,指出我的不足 谢谢

浙公网安备 33010602011771号