因此,当我尝试在某些文本上添加白色时,它在浏览器中并没有改变。当我在 google chrome 上进行用户检查时,它显示文本为“color: rgb(34, 34, 34);”在代码中我输入“color:white;”
HTML:
<div id="features">
<div id="features-filter"></div>
<div id="features-text">
<h1>Features</h1>
</div>
</div>
CSS:
#features {
background: url("img/server-room.jpg") no-repeat center;
background-size: cover;
position: relative;
height: 70%;
z-index: 99;
}
#features-filter {
position: absolute;
background: url("img/dot.png") repeat;
z-index: 999;
width: 100%;
height: 100%;
}
#features-text {
position: absolute;
z-index: 999;
}
#features-text h1 {
color: white;
}
最佳答案
这可能是一个缓存问题。
或者,在您将颜色更改为白色后,您的 CSS(或其他样式表)中可能存在定义元素样式的规则。
当你检查它时,“color: rgb(34, 34, 34);”在哪里?样式定义自?它是根据您编写的#features-text h1 定义的,还是由样式表(或另一个样式表)中其他地方的另一个规则定义的?如果它是在其他地方定义的 - 找出并确保该规则是' 覆盖您定义的样式。
或者,如果它被您无法访问/编辑的样式表应用,并且您需要在样式表中专门定义它,请尝试使用:
#features-text h1 {
color: white !important;
}
关于html - CSS 文本不改变颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39402709/