两个div左右浮动:当页面调整大小时,我如何保持它们在同一水平? [英] Two divs floating left and right: How can I keep them on the same level when a page resizes?

查看:379
本文介绍了两个div左右浮动:当页面调整大小时,我如何保持它们在同一水平?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定以下HTML:

<!DOCTYPE html>
<html>
<body>
  <div id="container">
    <div id="left" style="float: left; background-color: #777; width: 500px;">
      Here is some content. Blah blah blah etc.
      <div style="height: 50px;">Some more content</div>
      And finally some more.
    </div>
    <div id="right" style="float: right; background-color: #aaa; width: 500px;">
      Here is some content. Blah blah blah etc.
      <div style="height: 50px;">Some more content</div>
      And finally some more.
    </div>
    <div style="float: clear;"></div>
  </div>
</body>
</html>

我可以做什么 div#container 或其他标记,以防止 div#right div#left 下移动时调整浏览器窗口大小,宽度小于 1000px

What can I do to div#container or another tag to prevent div#right from moving under div#left when I resize the browser window such that the windows width is smaller then 1000px?

推荐答案

设置 min-width 到您的容器:

#container {
  min-width: 1000px;
}

这篇关于两个div左右浮动:当页面调整大小时,我如何保持它们在同一水平?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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