如何避免在CSS float中包装 [英] How to avoid wrapping in CSS float

查看:107
本文介绍了如何避免在CSS float中包装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我的问题是,当我将浏览器缩小时,右栏就会落在左栏的下方。



如何避免这种情况?



谢谢

解决方案

将父容器设置为固定宽度或将溢出设置为auto。

 < div style =width:400px; overflow:auto;> 
< div style =float:left; width:200px;>< / div>
< div style =float:left; width:200px;>< / div>
< / div>


I have a page with 2 columns side by side (defined both by float: left).

My problem is, when I scale the browser to be smaller, the right column will be dropped below the left column.

how can I avoid this? and still to make them be side-by-side no matter the screen size.

Thank you

解决方案

Make the parent container a fixed width or set the overflow to auto. For example if your two columns are 200px wide

<div style="width: 400px; overflow: auto;">
  <div style="float: left; width: 200px;"></div>
  <div style="float: left; width: 200px;"></div>
</div>

这篇关于如何避免在CSS float中包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆