我想做的是无论阅读器的屏幕分辨率有多大,背景颜色都将保持不变。我创建了一个 div,其高度设置为自动。
.news-box{
margin-top:5%;
border-radius:6px;
background-color: #EEE;
border: 1px solid #EEE;
margin-left: 24%;
height:auto;
width:620px;
}
这是它的样子
这是我对整个 html 的 CSS 规则
我正在使用这个 body css 规则。对于我的渐变
整个页面的 CSS 规则
html
{
height:100%;
}
这在 .news-box 类之前出现
body
{
background: rgb(125,126,125); /* Old browsers */
background: -moz-linear-gradient(top, rgba(125,126,125,1) 39%, rgba(14,14,14,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(39%,rgba(125,126,125,1)), color-stop(100%,rgba(14,14,14,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(125,126,125,1) 39%,rgba(14,14,14,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#7d7e7d', endColorstr='#0e0e0e',GradientType=0 ); /* IE6-9 */
}
这是没有 Div 的页面的样子
有什么办法可以解决这个问题吗?
最佳答案
Demo ................................................................
嘿,现在习惯了 min height
100%
在你的 html 和 body
中,就像这样
html, body{
min-height:100%;
}
关于html - 超越背景颜色的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12033529/