如何在css中设置整个页面的背景颜色

ros*_*tam 16 html css jquery-ui-css-framework

我试图将yumdom.com页面的背景颜色设置为黄色.

我尝试了以下内容但它失败了:

body{ background-color: yellow;} /*only a sliver under the header turns yellow.*/

#doc3{ background-color: yellow;} /*result same as above*/

#bd { background-color: yellow;} /*result same as above*/

#yui-main { background-color: yellow;} /*a rectangle turns yellow ending at where the content ends. I want this rectangle to extend all the way to the footer.*/
Run Code Online (Sandbox Code Playgroud)

另请注意,如果在Chrome中的开发人员工具中我突出显示上面的某个html元素,我只会突出显示该页面的某个部分.页脚和内容下方的部分保持不突出显示.

我希望黄色填充页眉和页脚之间的整个空间,不留空白区域.

请注意,我们使用YUI重置,字体和网格CSS模板V 2.8.0r4

非常感谢!

小智 15

正文的大小是动态的,它仅与其内容的大小一样大。在 css 文件中,您可以使用: * {background-color: black}// 所有元素现在都有黑色背景。

或者

html {background-color: black} // 页面现在有黑色背景,所有元素保持不变。


小智 9

<html>
  <head>
    <title>
        webpage
      </title>
</head>
  <body style="background-color:blue;text-align:center">
    welcome to my page
    </body>
  </html>
Run Code Online (Sandbox Code Playgroud)


ros*_*tam 8

我已经写了这个答案,但似乎已被删除。问题是 YUI 添加background-color:white到了 HTML 元素。我重写了它,从那里一切都很容易处理。


Bri*_*ver 5

问题在于页面的主体实际上是不可见的。下方的DIV的宽度为100%,并且本身具有覆盖主体CSS的背景色。

要修复无人区,这可能会起作用。它不优雅,但可以。

#doc3 {
    margin: auto 10px;
    width: auto;
    height: 2000px;
    background-color: yellow;
}
Run Code Online (Sandbox Code Playgroud)