您的位置:首页 > Web前端 > CSS

html 学习(css class选择器)

2016-05-17 21:00 721 查看
http://www.jianshu.com/p/802afaab545b

一般情况下,css 根据class修改标签,js根据id修改标签。

.A.B.C 与 .A .B .C 与 .A,.B,.C的区别(ABC分别为标签的class name)

.A.B.C 指同时包含三个class的标签
.A .B .C 指在class 为A 的标签下的class 为B的标签下的class为C的标签。(即:按照class 依次向下寻找)

.A,.B,.C 指标签为.A或.B或.C的所有标签(或关系)

例如:

<a href="#" class="one two three"> title one </a>
</br>
<a href="#" class="one two"> title two</a>
[/code]
以下css 修改了包含class one , class three的所有标签, 也就是说title one,title two都会被修改

.one,.three{
background-color: red;
}
[/code]
以下css修改了同时包含class one, class three的所有标签,即title one被修改,而title two 没有变化

.one.three{
background-color: red;
}
[/code]
以下css修改了 class 为one下的class为three的标签, 也就是说title one, title two 都没有被修改

.one .three{
background-color: red;
}
[/code]

文/某个胖子(简书作者)

原文链接:http://www.jianshu.com/p/802afaab545b

著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: