2013-02-20 95 views
0

我有一個網頁文本溢出一個容器div,即使在將height:auto;應用於包含div之後。頁面的補上看起來是這樣的:文本溢出容器後添加高度:自動到容器

<html> 
<head> 
<body> 
<div id="wrapper"> 

    <div id="inner_wrapper"> 

     <div id="content_left"> 
       <div class="main_content_text"> 
         Overflowing text 
       </div><!--end of main_content_text--> 
     </div><!--end of content_left--> 

     <div id="content_right"> 
     </div><!--end of content_right--> 

    </div><!--end of inner_wrapper--> 
</div><!--end of wrapper--> 
</body> 
</html> 

的CSS我使用看起來像這樣:

#inner_wrapper{ 
width: 100%; 
background-color: white; 
min-height: 900px; 
height: auto; 
margin: 0px auto; 
    } 

#content_left{ 
padding: 10px; 
margin: 10px 10px 30px 20px; 
width: 57%; 
min-height: 300px; 
float: left; 
} 

.main_content_text{ 
width: 625px; 
height: auto; 
font-weight: normal; 
font-family: 'Source Sans Pro','Ubuntu Light','Ubuntu Condensed',Ubuntu,Tahoma,Arial,sans-serif; 
font-size: 15px; 
line-height: 20px; 
margin-top: 30px; 
padding-bottom: 10px; 
} 

我,我將它的頁面在這裏Website

回答

0

添加以下規則

#inner_wrapper:after {content:「」;顯示:塊;溢出:隱藏;明確:兩者;身高:0; }

它會清除浮動,不需要增加額外的<div class="clear">元素

0

設置overflow:auto您需要的DIV!