Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.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/35.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,这是我的样式表 我试图让我身体周围的边缘与身体本身的颜色不同。这是我的开始代码。重置部分真的有必要吗?谁能告诉我我做错了什么 @charset "utf-8"; html { color: #d9a552; } body { display: table; margin: auto; background: white ; width: 960px; margin-top: 20px; max-width: 1050px; he

这是我的样式表

我试图让我身体周围的边缘与身体本身的颜色不同。这是我的开始代码。重置部分真的有必要吗?谁能告诉我我做错了什么

@charset "utf-8";
html {
    color: #d9a552;
}

body {
    display: table;
    margin: auto;
    background: white ;
    width:  960px;
    margin-top: 20px;
    max-width: 1050px;
    height: 100%;
    font-weight: 300;
}

你要找的是边界。如果要使身体周围的边距变红,只需使用以下命令:

body {
    margin: 0;
    border: 10px solid red;
    /*and this is to make it stretch all the way*/
    height: 100%;
    box-sizing: border-box;
}
html {height:100%;}

从中可以看出。

您可能需要尝试添加填充顶部:20px;以html代替页边空白:20px;与正文一起:

<html>
<head>

<style>
html {  
padding-top: 20px;
background: #d9a552;
}

body {
display: table;
margin: auto;
background: white;
width:  960px;
max-width: 1050px;
height: 100%;
font-weight: 300;
}
</style>

</head>

<body>
&nbsp;
</body>
</html>


下面是我的解决方案:我在body标签后面添加了section标签。我给它一个类id“mainBody”。然后我对代码进行了如下调整: 我知道我不能给自己荣誉,但我想我会和别人分享我的解决方案。我会赞扬你们两位引导我朝着正确的方向前进。
谢谢…

html元素实际上不是用来设计样式的。如果你想设计你的网页,你应该使用
div
s,而不是简单地将你的风格应用到
html
元素。最终,Joetje50是正确的——一个100%大小的包装div会更理想,但是你会看到一些人根据需要使用html元素。我要做的是:问题是如果我展开窗口,白色部分会返回。
background: #d9a552;
background-color: #d9a552;