Maison > interface Web > tutoriel HTML > le corps du texte

怎么让DIV自己伸缩?_html/css_WEB-ITnose

WBOY
Libérer: 2016-06-21 09:47:45
original
1334 Les gens l'ont consulté

    <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>
Copier après la connexion

让外面那个大的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>
Copier après la connexion
Copier après la connexion

在最后加一个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>
Copier après la connexion
Copier après la connexion

在最后加一个div,做浮动清除,要不然父元素不会自动适应的。
我擦这是为什么???

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!