Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 覆盖CSS背景属性_Html_Css_Background - Fatal编程技术网

Html 覆盖CSS背景属性

Html 覆盖CSS背景属性,html,css,background,Html,Css,Background,我有一个容器,它通过为全局css文件指定一个类名来继承一些设置。但是,当我尝试使用另一个类来更具体地设置背景时,没有任何变化 我的html中有趣的部分: <html> <head> <link rel="stylesheet" type="text/css" href="/styles/global.css"> <link rel="stylesheet" type="text/cs

我有一个容器,它通过为全局css文件指定一个类名来继承一些设置。但是,当我尝试使用另一个类来更具体地设置背景时,没有任何变化

我的html中有趣的部分:

    <html>
        <head>
            <link rel="stylesheet" type="text/css" href="/styles/global.css">
            <link rel="stylesheet" type="text/css" href="/styles/register.css">
        </head>
        <body class="class1 class2">
            <div>
                some content
            </div>
        </body>
    </html>
最后是注册的CSS

    .class2 {
        color: black;
        background-color: lightgray;
    }

文本颜色完全覆盖,但我无法更改背景。

CSS上不存在文本颜色。它是颜色


关于背景,请尝试同时使用background属性,而不仅仅是背景颜色。可能是浏览器渐变覆盖了它。

谢谢!我也总是把代码中的文本颜色弄乱。我对CSS太陌生了。
    .class2 {
        color: black;
        background-color: lightgray;
    }