作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
CSS 背景颜色给我带来了问题。样式 block 需要使用“.land.custom_one”而不是普通的“.custom_one”才能工作。从 td-class 中删除“land”也可以使它工作,但我需要悬停的“land”-class 才能工作,因为它不是所有需要悬停效果的 tds。样式 block 在 style.css 之后定义。我在 Chrome 和 Firefox 中都遇到了这个问题。
style.css
#id table {
background-color: blue;
}
#id td.land {
background-color: green;
}
#id td.land:hover {
background-color: black;
color: orange;
}
style block
.custom_one {
background-color: red;
color: white;
}
html
<td class="land custom_one"></td>
最佳答案
选择器的特异性计算如下:
连接三个数字 a-b-c(在大基数的数字系统中)给出特异性。
元素选择器:0, 0, 1 (1)
类选择器 0, 1, 0 (10)
ID 选择器 1, 0, 0 (100)
CSS:
.blue {
font-color:blue;
}
#red {
font-color:red;
}
HTML:
<div class="blue">
<div class="blue">
<div class="blue">
<div id="red">this text will be red</div>
</div>
</div>
</div>
最好的解释方法是这个人做了什么:CSS: Specificity Wars
关于CSS 背景颜色很挑剔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3089605/
我是一名优秀的程序员,十分优秀!