Css 使用边距沿边位置

Css 使用边距沿边位置,css,Css,我正在使用下面的css,我得到的高度很好,但它松开了边距:0 auto。如何更改css以获得完整的窗口高度和div中心 CSS: .container{ width:960px; position: absolute; top: 0px; bottom: 0px; margin: 0 auto; background:url('../img/bg.png') repeat; background-size:100% 100%; } 这可能

我正在使用下面的css,我得到的高度很好,但它松开了
边距:0 auto
。如何更改css以获得完整的窗口高度和div中心

CSS:

.container{
    width:960px;
    position: absolute;
    top: 0px;
    bottom: 0px;
    margin: 0 auto;
    background:url('../img/bg.png') repeat;
    background-size:100% 100%;
}

这可能会导致进一步的问题,但基本思想是强制
body
html
具有
100%的高度

HTML

小提琴:

编辑:很抱歉,当我说进一步的问题时,我的意思是拉伸嵌套的div以拉伸窗口的整个高度会很困难,因为在这种情况下,您必须强制链中的每个元素具有
最小高度:100%

像下面这样

<div class="some-wrapper">
    <div class="content-wrapper">
        <div class="some-other-div">
        </div>
    </div>
</div>

要使
。其他一些div
成为窗口的全高,您必须添加
最小高度:100%
。一些包装,.content包装
,有点难看

html,
body {
    margin:0;
    height:100%;
}

.page {
    min-height:100%;
    margin:0 auto;
    width:300px;
    background:green
}
<div class="some-wrapper">
    <div class="content-wrapper">
        <div class="some-other-div">
        </div>
    </div>
</div>