0

我想要做的是,无论屏幕分辨率对读者来说有多大,背景颜色都将保持不变。我创建了一个高度设置为自动的 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 的页面的样子

在此处输入图像描述

有任何解决这个问题的方法吗?

4

1 回答 1

1

演示.....................

嘿,现在习惯min height 100%了你html and body这样

html, body{
min-height:100%;

}

演示

于 2012-08-20T07:15:01.363 回答