html - 超越背景颜色的div

标签 html css web-applications stylesheet

我想做的是无论阅读器的屏幕分辨率有多大,背景颜色都将保持不变。我创建了一个 div,其高度设置为自动。

.news-box{
margin-top:5%;
border-radius:6px;
background-color: #EEE;
border: 1px solid #EEE;
margin-left: 24%;
height:auto;
width:620px;
}

这是它的样子

enter image description here

这是我对整个 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 的页面的样子

enter image description here

有什么办法可以解决这个问题吗?

最佳答案

Demo ................................................................

嘿,现在习惯了 min height 100% 在你的 html 和 body 中,就像这样

html, body{
min-height:100%;

}

Demo

关于html - 超越背景颜色的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12033529/

相关文章:

html - 如何将字体样式导入css并在页面中使用?

html - 如何使用CSS将 Logo 放在中心

python - HTML/CSS 作为 python 脚本的 GUI?

css - aspx ASP.NET 设置 CssClass

php - 在提交 POST 表单后使用 anchor

javascript - 底面布局

javascript - 使用 HTML 并排显示两个文档

javascript - 将 CSS 注入(inject)网站

css - 如何在页面中包含 100% 的背景图片

web-applications - iphone 4 移动版 Safari 中的图像模糊