div ul li 嵌套後解決高度自適應方法__div

來源:互聯網
上載者:User

方法一:



div 自適應寬度
很簡單 ,你應該設定div的display:inline-block
然後不要設定寬度就行了


方法二: 

<body bgcolor="#0B3D82">  
div ul li 嵌套後解決高度自適應辦法:
html代碼如下
<div class="main_div">
<ul>
<li><a href="#"><img src="images/img.gif" width="80" height="90" /><span class="front12_arial">daugli-1webServer-1web Server</span></a></li>
<div style="clear:both;"></div>
<ul>
<div class="main_div">
 
CSS代碼如下:
.main_div {
 width:80%;
 margin-top: 15px;
 margin-right: 26px;
 margin-bottom: 15px;
 margin-left: 26px;
}
.main_div ul {
 min-height:205px;
 height:auto;
}
.main_div li {
float:left;
text-align:center;
height:170px;
width:130px;
border:1px solid #CCC;
margin-right:10px;
margin-bottom:15px;
padding:10px;
}
 
目的:增加多個li後,DIV高度自動適應。
思路:定義li高度為絕對值 205px,定義ul高度為自動 {min-height:205px;  height:auto;} main_div 高度為 空
注意:
1. min-height:205px;  height:auto; 意思為最小高度為205,超過以後自適應
2. 增加<div style="clear:both;"></div> 清除換行
3. 本例在IE6下和Chrome下測試正常

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.