html - CSS 文本不改变颜色

标签 html css

因此,当我尝试在某些文本上添加白色时,它在浏览器中并没有改变。当我在 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/

相关文章:

css - 使单元格内容适合 HTML CSS 表格中的单元格高度

html - 覆盖 WordPress Enfold 中自动生成的最大宽度 CSS 规则

html - 无法使元素 (3) 在其他元素 (3) 之上居中,flexbox

html - 为什么两个跨度不能在div中居中?

css - 重叠 Div 定位

html - 将图像制作成盒子

css - float 和列表样式位置 : inside, 在最新的 chrome 中不起作用?

javascript - 如何使用 javascript 永久更改我网站中的 css 文件?

css - 带有 CSS 网格的砌体布局

css - Internet Explorer 8 和复选框 CSS 问题