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 背景div颜色和内容div的颜色,使它们不同_Html_Css - Fatal编程技术网

Html 背景div颜色和内容div的颜色,使它们不同

Html 背景div颜色和内容div的颜色,使它们不同,html,css,Html,Css,你可能对我放的方式感到困惑,让我展示一下。 输入或时,背景色为灰色,但包含内容的部分为白色。如何使我的html看起来像那样?是否将背景设置为灰色,而内容分区设置为白色 这是我的建议 CSS HTML body{ background-color:#CCC; } #main{ width:70%; height:600px; top:20px; margin-left:15%; background-color:#FFF; } <body> <div id=

你可能对我放的方式感到困惑,让我展示一下。 输入或时,背景色为灰色,但包含内容的部分为白色。如何使我的html看起来像那样?是否将背景设置为灰色,而内容分区设置为白色

这是我的建议

CSS

HTML


body{
background-color:#CCC;
 }
 #main{
 width:70%;
 height:600px;
 top:20px;
 margin-left:15%;
 background-color:#FFF;
 }
<body>
<div id="main"></div>
</body>