Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent the floating layout wrapping when firefox zoom is reduced

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>
like image 393
Dmitri Zhuchkov Avatar asked Aug 13 '09 19:08

Dmitri Zhuchkov


People also ask

How do I stop a CSS layout from distorting when zooming out?

To fix the problem with zooming in, try adding the min-width attribute to your outer countainer ( #container or #navbar ?). Setting min-width prevents the webpage from trying to shrink down beyond the specified width (i.e. 300px).

How do you make the page layout stay the same after minimized?

Add width: 1000px; to your container. Then the layout should stay consistent.

How do I stop Firefox from zooming in automatically?

Luckily, if you're as annoyed as I am about this, there is a quick and easy fix. Step One: Open up Firefox and click the address bar (where you enter a URL) and then type about:config and press ENTER. Step Two: You'll see a warning pop up. Go ahead and click the button that says, “I'll be careful, I promise!”

How do I zoom the same element size?

min-width: 100%; This will freeze the width, you can do the same for height too.


Video Answer


1 Answers

Try switching to a different box model as follows:

#left, #right 
{ 
  width:480px;
  border:1px solid;
  box-sizing: border-box;

  /* and for older/other browsers: */
  -moz-box-sizing: border-box;
  -ms-box-sizing: border-box;
  -webkit-box-sizing: border-box
}
like image 192
ЯegDwight Avatar answered Sep 28 '22 00:09

ЯegDwight