html 学习(css class选择器)
2016-01-28 本文已影响184人
某个胖子
一般情况下,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>
以下css 修改了包含class one , class three的所有标签, 也就是说title one,title two都会被修改
.one,.three{
background-color: red;
}以下css修改了同时包含class one, class three的所有标签,即title one被修改,而title two 没有变化
.one.three{
background-color: red;
}
以下css修改了 class 为one下的class为three的标签, 也就是说title one, title two 都没有被修改
.one .three{
background-color: red;
}