How to prevent the floating layout wrapping when f

2019-02-02 08:39发布

Given the following HTML. It display two columns: #left, #right. Both are fixed width and have 1px borders. Width and borders equal the size of upper container: #wrap.

When I zoom out Firefox 3.5.2 by pressing Ctrl+- columns get wrapped (demo).

How to prevent this?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test</title>
    <style type="text/css">
      div           {float:left}
      #wrap         {width:960px}
      #left, #right {width:478px;border:1px solid}
    </style>
  </head>
  <body>
    <div id="wrap">
      <div id="left">
        left
      </div>
      <div id="right">
        right
      </div>
    </div>
  </body>
</html>

9条回答
别忘想泡老子
2楼-- · 2019-02-02 09:22

I encountered the same issue described above. After, hopelessly wandering around the internet for a few minutes, I found out that apparently it's a bug in Firefox 3.5.x and IE 7/8. The bug is still present as of this writing.

To see more about the bug go here: http://markasunread.com/?p=61 (formerly http://markasunread.com/2009/06/zoom-bug-in-ie78-and-firefox-caused-by-border/)

查看更多
做个烂人
3楼-- · 2019-02-02 09:22

Best Solution to fix floating bug in every case is use table layout using tds. That will never loose floating.

查看更多
狗以群分
4楼-- · 2019-02-02 09:25

Ok guys, when you have a div with fixed height, to prevent zoom from breaking up everything, add overflow:hidden to it's css. That did the trick for me and now every browser can go zoom crazy. :)

查看更多
登录 后发表回答