Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.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 背景色保持白色_Html_Css - Fatal编程技术网

Html 背景色保持白色

Html 背景色保持白色,html,css,Html,Css,我正在建立一个网站,但由于某种原因,我的背景色不起作用。什么也没发生,背景色保持白色 不工作的代码如下所示: .sub-header { background-color: black !important; } 我在jsfiddle上的完整代码:有趣的行是158159160。这是因为子标题中的所有元素都不在流中(因为绝对位置) 注意:我添加显示:块使背景色属性占据所有行,而不仅仅是标题“Chezzles”,但如果需要,您可以保持内联。如果我理解正确,您将尝试执行以下操作: HTML

我正在建立一个网站,但由于某种原因,我的
背景色不起作用。什么也没发生,
背景色保持白色

不工作的代码如下所示:

.sub-header {
    background-color: black !important;
}

我在jsfiddle上的完整代码:有趣的行是158159160。

这是因为
子标题中的所有元素都不在流中(因为绝对位置)


注意:我添加
显示:块
使
背景色
属性占据所有行,而不仅仅是标题“Chezzles”,但如果需要,您可以保持
内联

如果我理解正确,您将尝试执行以下操作:

HTML

<header class="sub-header">
  <div class="dropdown">
    <a href="#" class="main-navbar-heading-2">Chezzles</a>
    <i class="fa fa-bars fa-fw bars" style="font-size:24px"></i>
  </div>
</header>

就像这把小提琴一样

。子标题
的高度为零,因为您正在浮动它的子标题。这和
页边距顶部有什么关系?
?你的标题和问题似乎不同。萝卜我把页边距顶部放在旁边mistake@ShreyasSreenivasa然后更改标题。
<header class="sub-header">
  <div class="dropdown">
    <a href="#" class="main-navbar-heading-2">Chezzles</a>
    <i class="fa fa-bars fa-fw bars" style="font-size:24px"></i>
  </div>
</header>
.sub-header {
        background-color: black !important;
    }
    .sub-header .dropdown {
        background-color: black !important;
        width: 100%;
        height: 25px;
        padding: 5px;
    }
    .sub-header .dropdown * {
      color: white;
    }
    .sub-header .dropdown i {
      top: 15px;
    }

    .main-navbar-heading-2 {
        top: 5px;
        left: 5px;
        text-decoration: none;
        color: black;
        font-family: Raleway;
        font-size: 1.3em;
    }