I have 2 divs: one in the left side and one in the right side of my page. The one in the left side has fixed width and I want the one of the right side to fill the remaining space.
#search {
width: 160px;
height: 25px;
float: left;
background-color: #ffffff;
}
#navigation {
width: 780px;
float: left;
background-color: #A53030;
}
<div id="search">Text</div>
<div id="navigation">Navigation</div>
Here is a little fix for accepted solution, which prevents right column from falling under the left column. Replaced
width: 100%;
withoverflow: hidden;
a tricky solution, if somebody didn't know it.http://jsfiddle.net/MHeqG/2600/
[edit] Also check an example for three column layout: http://jsfiddle.net/MHeqG/3148/
/* * css */
/* * html */
new to css. But I solved this problem by using inline-block. check this out: http://learnlayout.com/inline-block.html
I tried the above solutions for a liquid left, and a fixed right but non of them worked (I am aware the question is for the reverse but I think this is relevant). Here's what did work:
I had a similar issue and came up with the following which worked well
CSS:
HTML:
This method won't wrap when the window is shrunk but will auto expand the 'content' area. It will keep a static width for the site menu (left).
And for auto expanding content box and left vertical box(site menu) demo:
https://jsfiddle.net/tidan/332a6qte/
Try adding position
relative
, removewidth
andfloat
properties of the right side, then addleft
andright
property with0
value.Also, you can add
margin left
rule with the value is based on the left element's width (+ some pixels if you need space in between) to maintain its position.This example is working for me: