第二行的DIV无法靠上对齐 会按第一行最高的对齐,无法填满

Xiang.Yuan 2013-12-10 02:47:30

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

如题, 怎么让 div3 紧挨 div1 进行显示, 求兄弟姐妹 帮忙 !
...全文
384 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Go 旅城通票 2013-12-12
  • 打赏
  • 举报
回复
引用 4 楼 Hell0__World 的回复:
先谢谢各位的回答, 可能我的问题没表述清楚 , 我现在是从后台返回一个集合在 前台循环出来, 可能有10来个Div , 每个Div的高度都是自适应 , 我并不知道得把哪个 设成 float:left 或 float:right , 用绝对定位的话, 高度也不好确定
瀑布流masonry这个插件,自动帮你计算位置高度,放到合适的位置
Xiang.Yuan 2013-12-12
  • 打赏
  • 举报
回复
引用 5 楼 showbo 的回复:
[quote=引用 4 楼 Hell0__World 的回复:] 先谢谢各位的回答, 可能我的问题没表述清楚 , 我现在是从后台返回一个集合在 前台循环出来, 可能有10来个Div , 每个Div的高度都是自适应 , 我并不知道得把哪个 设成 float:left 或 float:right , 用绝对定位的话, 高度也不好确定
瀑布流masonry这个插件,自动帮你计算位置高度,放到合适的位置[/quote] 谢谢!
舒克是我 2013-12-12
  • 打赏
  • 举报
回复
楼上正解,用瀑布流处理吧
Xiang.Yuan 2013-12-11
  • 打赏
  • 举报
回复
先谢谢各位的回答, 可能我的问题没表述清楚 , 我现在是从后台返回一个集合在 前台循环出来, 可能有10来个Div , 每个Div的高度都是自适应 , 我并不知道得把哪个 设成 float:left 或 float:right , 用绝对定位的话, 高度也不好确定
KK3K2005 2013-12-10
  • 打赏
  • 举报
回复
<div style=" float:left ; width:850px; " id="container"> <div style="float:right; width:400px; height:200px; background:#0C3">div2</div> <div style="float:left; width:400px; height:100px; background:#CCC">div1</div> <div style="float:left; width:400px; height:100px; background:#660">div3</div> </div>
KeepSayingNo 2013-12-10
  • 打赏
  • 举报
回复
你用下面布局就可以了。

<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>


Go 旅城通票 2013-12-10
  • 打赏
  • 举报
回复
<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>

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧