我想要一个全灰色的背景,里面有一个较小的蓝色背景。
有点像
<body>
<div id= "background_1">
<div id= "background_2">
</div>
</div>
</body>
然后在css中
#background_1
{
background-color : gray;
z-index : 1;
}
#background_2
{
background-color : blue;
z-index : 2;
}
谁能帮我解决这个问题?我知道它有点模糊,但我基本上想要一个全灰色的背景,前景中有一个较小的蓝色矩形。
最佳答案
您的代码一切正常...但不需要 z-index。
也许,将一些内容放入您的 div 中,或者固定它们的大小
编辑您的其他问题
// HTML
<body>
<div id= "background">
Test content
</div>
</body>
// CCS
html,body
{
margin:0 20px 0 20px;
background-color : gray;
height: 100%;
}
#background
{
width:100%;
height: auto !important;
height: 100%;
min-height: 100%;
background-color : blue;
}
你可以在这里看到结果:http://jsfiddle.net/Nz5WK/1/
关于html - CSS定位/颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9338003/