我想让旋转木马DIV (s7)扩展到整个屏幕的高度。我不知道为什么它不成功。要查看页面,您可以点击这里。

body { height: 100%; color: #FFF; font: normal 28px/28px'HelveticaWorldRegular', Helvetica, Arial, Sans-Serif; background: #222 url('') no-repeat center center fixed; overflow: hidden; background-size: cover; margin: 0; padding: 0; } .holder { height: 100%; margin: auto; } #s7 { width: 100%; height: 100%: margin: auto; overflow: hidden; z-index: 1; } #s7 #posts { width: 100%; min-height: 100%; color: #FFF; font-size: 13px; text-align: left; line-height: 16px; margin: auto; background: #AAA; } <div class="nav"> <a class="prev2" id="prev2" href="#"> <img src="http://static.tumblr.com/ux4v5bf/ASslogxz4/left.png"> </a> <a class="next2" id="next2" href="#"> <img src="http://static.tumblr.com/ux4v5bf/swslogxmg/right.png"> </a> </div> <div class="holder"> <tr> <td> <div id="s7"> {block:Posts} <div id="posts">


当前回答

如果你将元素放置在div中,你可以将顶部和底部的填充设置为50%。

就像这样:

#s7 {
    position: relative;
    width:100%;
    padding: 50% 0;
    margin:auto;
    overflow: hidden;
    z-index:1;
}

其他回答

你还需要在html元素上设置100%的高度:

html { height:100%; }

或者,如果你使用position: absolute,那么height: 100%也可以。

对于不想使用html, body, .blah {height: 100%}的人,这里有另一个解决方案。

.app { 位置:固定; 左:0; 右:0; 上图:0; 底部:0; overflow-y:汽车; } .full-height { 高度:100%; } test { 宽度:10 px; 背景:红色; } < div class = "应用" > <div class="全高测试"> < / div > 滚动也可以 < / div >

如果你将元素放置在div中,你可以将顶部和底部的填充设置为50%。

就像这样:

#s7 {
    position: relative;
    width:100%;
    padding: 50% 0;
    margin:auto;
    overflow: hidden;
    z-index:1;
}

在页面源代码中,我看到以下内容:

<div class="holder"> 
    <div id="s7" style="position: relative; width: 1366px; height: 474px; overflow: hidden;">

如果您将高度值放在标记中,它将使用此值而不是css文件中定义的高度。