Waleed Waleed - 4 years ago 458
HTML Question

Two divs side by side - Fluid display

I am trying to place two divs side by side and using the following CSS for it.

#left {
float: left;
width: 65%;
overflow: hidden;
}

#right {
overflow: hidden;
}


The HTML is simple, two left and right div in a wrapper div.

<div id="wrapper">
<div id="left">Left side div</div>
<div id="right">Right side div</div>
</div>


I have tried so many times to search for a better way on Stackoverflow and other sites too, But couldn't find the exact help.

So, the code works fine in first glance. Problem is this, that the left div gets padding/margin automatically as I increase width in (%). So, at 65% width, the left div is having some padding or margin and is not perfectly aligned with the right div, I tried to padding/margin 0 but no luck. Secondly, If I zoom in the page, the right div slides below the left div, Its like not fluid display.

Note: I am sorry, I have searched alot, this question has been asked many times but those answers aren't helping me, I have explained what is problem in my case.

I hope there is a fix for that.

Thank you.

EDIT: Sorry, me HTML problem, There were two "box" divs in both left and right sides, They had padding in %, So left side showed more padding because of greater width. Sorry, The above CSS works perfect, its fluid display and fixed, Sorry for asking wrong question....

Answer Source

Using this CSS for my current site. It works perfect!

#sides{
margin:0;
}
#left{
float:left;
width:75%;
overflow:hidden;
}
#right{
float:left;
width:25%;
overflow:hidden;
} 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download