首頁  >  文章  >  web前端  >  第二行的DIV无法靠上对齐 会按第一行最高的对齐,无法填满_html/css_WEB-ITnose

第二行的DIV无法靠上对齐 会按第一行最高的对齐,无法填满_html/css_WEB-ITnose

WBOY
WBOY原創
2016-06-21 09:47:371315瀏覽

html代码:

    
div1

    
div2

    
div3
   


如题,  怎么让 div3 紧挨 div1 进行显示, 求兄弟姐妹 帮忙  ! 

回复讨论(解决方案)

<div style=" float:left ; width:850px; " id="container">    <div style="float:right; width:400px; height:200px; background:#0C3">div2</div>     <div style="width:400px; height:100px; background:#CCC">div1</div>    <div style="width:400px; height:100px; background:#660">div3</div>  </div>

你用下面布局就可以了。

<div style=" float:left ; width:850px; " id="container">	<div style="float:left;">		<div style="width:400px; height:100px; background:#CCC">div1</div>		<div style="float:left; width:400px; height:100px; background:#660">div3</div> 	</div>  	    <div style="float:left; width:400px; height:200px; background:#0C3">div2</div>  </div>



    
div2

    
div1


    
div3
   

先谢谢各位的回答, 可能我的问题没表述清楚 , 我现在是从后台返回一个集合在 前台循环出来, 可能有10来个Div , 每个Div的高度都是自适应 , 我并不知道得把哪个 设成 float:left 或 float:right , 用绝对定位的话, 高度也不好确定 

先谢谢各位的回答, 可能我的问题没表述清楚 , 我现在是从后台返回一个集合在 前台循环出来, 可能有10来个Div , 每个Div的高度都是自适应 , 我并不知道得把哪个 设成 float:left 或 float:right , 用绝对定位的话, 高度也不好确定 

用 瀑布流masonry这个插件,自动帮你计算位置高度,放到合适的位置

楼上正解,用瀑布流处理吧


先谢谢各位的回答, 可能我的问题没表述清楚 , 我现在是从后台返回一个集合在 前台循环出来, 可能有10来个Div , 每个Div的高度都是自适应 , 我并不知道得把哪个 设成 float:left 或 float:right , 用绝对定位的话, 高度也不好确定 

用 瀑布流masonry这个插件,自动帮你计算位置高度,放到合适的位置

谢谢!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn