日期:2014-05-17  浏览次数:20634 次

一个DIV隐藏后,其它DIV如何填上去??
我有四个DIV,排列如:
12
34
现在假设1被隐藏了,2就应该填补上来.变成:
23
4
这个怎么实现啊?
请大虾们帮帮忙吧.在线等~~~急啊~~~~~

------解决方案--------------------
好实现的 设置你的这四个div的样式float:left;就可以了,闲着没事,给你做个示例吧.
<div style="width:100px; margin:auto;">
<div id="div1" style="width:50px; float:left; background:Green;">1</div>
<div style="width:50px; float:left; background:Blue;">2</div>
<div style="width:50px; float:left; background:Red;">3</div>
<div style="width:50px; float:left; background:Yellow;">4</div>
<div style="clear:both;"></div>
</div>
<input type="button" value="隐藏1" onclick="document.getElementById('div1').style.display='none';" />