内容div 100%高度延伸太远

时间:2013-04-24 18:55:17

标签: css html

当内容本身不能正常扩展到页面底部时,我遇到了一些麻烦。如果内容很短并且没有填满页面,则容器仍会延伸到页面底部。

这是结构:

<div id="container">

    <div id="logo"></div>

    <div class="clear"></div>



<div class="spacer"></div>

<div class="content">


        <div class="post">

        <div class="right"></div>
    </div>


    <div id="centerit">/div>    
</div></body></html>

这是css:

body{background:url(bg.jpg);font-family:verdana, helvetica, sans-serif;font-size:12px;line-height:18px;color:#b3b3b3;height:100%;min-height:100%;}

    a{color:#fff;text-decoration:none;font-weight:bold;outline:none;}

    /* a:hover{color:#289bc6;} */

html { height: 100%; }
    #container{width:1200px;margin:auto;height:100%;position:relative;}

    #logo{font-size:18px;line-height:37px;color:#222;float:left;display:block;clear:both;}

    #nav{margin:auto;background:#000;padding;2px 800px 0px 0px;width:800px;}

    #nav li{display:inline;background:#000;}

    #nav li a{padding:9px 40px 10px 3px;font-weight:normal;color:#fff;background:#000;text-transform:uppercase;line-height:40px;}

#nav li a:hover, #nav li .active, #nav .current_page_item a, #nav li a.current_page_item{background:#fff;color:#000;}

    /* #nav li a:active{background:#289bc6;} */

    .clear{clear:both;}


    .spacer{height:10px;}

    .content{margin:auto;width:800px;height:100%;display:block;clear:both;position:relative;}

.sidebar{margin:auto;padding:10px;width:780px;background:#000;}

.sidebar h3{padding:5px 5px 4px 5px;background:#fff;color:#000;text-transform:uppercase;font-weight:normal;}

    #categories{border-bottom:1px solid #fff;line-height:21px;}

    #categories li{display:inline;margin:0 5px 0 0;}

    #categories li a{padding:5px;color:#fff;text-transform:uppercase;font-weight:normal;}

    #categories li a:hover, #categories li b{padding:5px 5px 4px 5px;background:#fff;color:#000;text-transform:uppercase;font-weight:normal;}

    /* #categories li a:active, #categories li b:hover, #categories li b:active{background:#289bc6;} */



                .post{background:#000;position:relative;clear:both;display:block;clear:both;width:800px;min-height:100%;margin-bottom: 30px;}

    .post .left{width:100px;float:left;margin-top:-10px;height:100%;}

    .post .left h5{font-weight:normal;line-height:72px;font-size:72px;margin-top:10px;}

    .post .left b{font-weight:normal;font-size:25px;line-height:25px;margin-top:-200px;}

    .post .right h2 a{text-transform:uppercase;padding:3px;font-weight:normal;font-size:30px;line-height:32px;}
    .post-390 .right h2 a {display: none;}

    .post .right h2 a:hover{text-decoration:underline;}

    .post .right{width:760px;height:90%;float:left;margin-left:10px;}



    .sidebar ul{line-height:21px;}

    .sidebar ul li{display:inline;margin:0 5px 0 0;}

    .sidebar ul li a{padding:5px;color:#fff;text-transform:uppercase;font-weight:normal;display:block;}

    .sidebar ul li a:hover{padding:5px;background:#fff;color:#000;text-transform:uppercase;font-weight:normal;}



    .footerul{line-height:21px;background:#000;}

    .footerul li{display:inline;margin:0 5px 0 0;}

    .footerul li a{padding:5px;color:#fff;text-transform:uppercase;font-weight:normal;display:block;}

    .footerul li a:hover, .footerul li b{padding:5px 5px 4px 5px;background:#fff;color:#000;text-transform:uppercase;font-weight:normal;}

    /* .footerul li a:active, .footerul li b:hover, .footerul li b:active{background:#289bc6;} */

    /* .footerul li b{border-bottom:1px solid #fff;width:100%;}*/



    #fleft{width:100%;float:left;}

    #fright{width:48%;float:right;}



    #centerit{text-align:center;background:#000;padding:10px 0px 10px 0px;position:fixed;bottom:0;width:800px;}



.commentlist li{padding:10px;background:#eee;}

.commentlist li.alt{background:#ddd;}

.alignright {float:right;}

.alignleft {float:left;}

1 个答案:

答案 0 :(得分:0)

调整并添加到混音中:

html { height: 100%; min-height: 100; /* min-height is for FF */ }
#content { height: -webkit-calc-height(100% - 37px); } /* be sure to add all vendor prefixes, also change 37px to the correct height of elements above the #content */