Jump to content

Recommended Posts

Hi all,

 

I just started writing a template that looks as follows

 

...
    <body>
        <div id="frame">
            <div id="left"></div>
            <div id="right"></div>
        </div>
    </body>
...

 

the css is

 

* {
padding: 0;
margin: 0;
}

#frame {
height: 100%;
width: 100%;
min-width: 800px;
}

#left {
float: left;
height: 100%;
width: 40%;
min-width: 300px;
}

#right {
float: right;
height: 100%;
width: 60%;
min-width: 500px;
}

 

So both min-width of #left/#right 300px and 500px add up to 800px which is the min-width of #frame.

Intuitively #left and #right should never be stacked vertically, as when the window size goes below 800px it automatically adds scrollbars to the window due to the min-width of #frame.

 

However they do get stacked vertically when resizing the window below 800px..

They already get stacked with widht 820px or even more.

 

As I set both padding and margin to 0, I don't see why they are already going to be stacked before windowsize < 800px.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/204779-inconsistent-px-width-on-floating-divs/
Share on other sites

Always good to include that info, though in this case it wasn't the browser (I thought you may be using IE6, which can do some funny thing with floated elements).

 

This one is a little tricky. It takes a bit of math. Look at it this way. Lets look a the sizes when the container is 800 px:

 

left: 800px * 40% = 320px;

right: 800px * 60% = 480px;

 

But you have given right a minimum width of 500px.

500px + 320px = 820px

820px is bigger than 800 px, so the two elements don't fit side-by-side in the container, and the right one drops down below where it can fit.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.