HTML – 如何避免空清除div?
发布时间:2020-12-14 21:15:07 所属栏目:资源 来源:网络整理
导读:我最近一直在使用很多漂浮物: div id="buttons" input type="button" id="btn1" value="Button One" input type="button" id="btn2" value="Button Two" input type="button" id="btn3" value="Button Three"/div 有时我会向右边的按钮浮动.有时我会将它们
我最近一直在使用很多漂浮物:
<div id="buttons"> <input type="button" id="btn1" value="Button One"> <input type="button" id="btn2" value="Button Two"> <input type="button" id="btn3" value="Button Three"> </div> 有时我会向右边的按钮浮动.有时我会将它们全部漂浮在右边.这是问题开始的地方.如果我这样做,它真的会抛弃流量所以我必须继续投入这些: <div style="clear:both;"></div> 最后.如果我没有将它们全部浮动,那将抛弃布局. 有一个很好的解决方案吗? 解决方法
是的,使用overflow:隐藏在容器上,即:
<style type="text/css"> #buttons { overflow: hidden; } </style> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |