Maison >interface Web >tutoriel HTML >怎么让DIV自己伸缩?_html/css_WEB-ITnose
<div style=" width:810px; background-color:#06F; min-height:210px;word-wrap:break-word;"> <div style="width:200px; height:200px; background-color:#0F0; float:left;">1</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">2</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">3</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">4</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">5</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">6</div> </div>
外面加样式
overflow:hidden
不设置高度就可以吧,把那个min-height去掉试试?
<div style=" width:810px; background-color:#06F; min-height:210px;word-wrap:break-word;"> <div style="width:200px; height:200px; background-color:#0F0; float:left;">1</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">2</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">3</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">4</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">5</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">6</div> <div style="clear:both;"></div> </div>
<div style=" width:810px; background-color:#06F; min-height:210px;word-wrap:break-word;"> <div style="width:200px; height:200px; background-color:#0F0; float:left;">1</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">2</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">3</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">4</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">5</div> <div style="width:200px; height:200px; background-color:#0F0; float:left;">6</div> <div style="clear:both;"></div> </div>