html - 页面换行不占用最小高度

标签 html css

我有以下代码

html ,body {
    height: 100%;
    font-style: Helvetica;
}
.page_background, .page { margin: 0 auto; }
.page_background {
    width: 100%;
    min-height: 100%;
    background: -webkit-linear-gradient(#282828, #888888); /* For Safari 5.1 to 6.0 */
    background: -o-linear-gradient(#282828, #888888); /* For Opera 11.1 to 12.0 */
    background: -moz-linear-gradient(#282828, #888888); /* For Firefox 3.6 to 15 */
    background: linear-gradient(#282828, #888888); /* Standard syntax */
    position: absolute;
    /*height: 100%;*/
}
.page {
    background-color: #FFFFFF;
    width: 85%;
    min-height: 100%;
    bottom: 0;
    position: absolute;
    height: 100%;
    left: 7.5%;
}

        <div class="page_background">
            <div class="page">
            </div>
        </div>

如果页面超过屏幕的整个高度(您必须滚动),背景颜色将不适用。我设置了 min-height: 100%; 并尝试了 height: 100%;。两者似乎都不起作用。我做错了什么?

最佳答案

您只需要重置默认浏览器样式 - 边距,就像这样

html ,body {
  height: 100%;
  font-style: Helvetica;
  margin :0;
}

https://jsfiddle.net/b0txv2m2/5/

关于html - 页面换行不占用最小高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32032523/

相关文章:

css - Flex-flow : column wrap. 如何设置容器的宽度等于内容?

css - 3个 float div在固定宽度的容器中,当三个div与固定div with border的尺寸相同时div向下跳转

javascript - 使用 jQuery 和 CSS 设计一个 d3 元素

javascript - Canvas 中的图像尺寸、比例错误并且变得模糊

javascript - 标题下显示 JQuery Mobile "Filter Items"

html - 使用 CSS 防止文本在锚定按钮上滚动

javascript - 事件处理麻烦JS

asp.net - 面板内的部分边框

html - 表头没有收到 CSS(我认为)

html - 如何将 div 相对于父 div 垂直居中对齐