tags:

views:

1848

answers:

2

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.

The one on the right side is the navigation and I want it to to fill the remaining space on it right side:

My CSS:

#search {
    width: 160px;
    height: 25px;
    float: left;
    background-color: #FFF;
}

#navigation {
    width: 780
    float: left; 
    /*background-color: url('../images/transparent.png') ;*/
    background-color: #A53030;
}

My Html:

<div id="search">

</div>
<?php include("navigation.html"); ?>
<div id="left-column">

Thank in advance!

+1  A: 

This seems to accomplish what you're going for.

<html>

<head>
 <title>This is My Page's Title</title>
 <style type="text/css">
  #left {
   float:left;
   width:180px;
   background-color:#ff0000;
  }
  #right {
   width: 100%;
   background-color:#00FF00;
  }
 </style>
</head>

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

 </html>
Boushley
You have to remove the width: 100% on the right div though to make it work.
Johan Leino
I just copy and pasted that code out of a page i tested it on... the 100% works.
Boushley
At least in chrome it does.
Boushley
thanks!! in never used %s before i think they are the key for flexibility
janoChen
A: 

@Boushley

I'm pretty sure the design suggested by Boushley breaks down if #right is higher than #left. Try inserting:

<p>right</p>
<p>right</p>
<p>right</p>

As the contents of #right to see what I mean.

( I'm told there is no way to comment directly on Boushley's answer which is what I would have preferred. )

Peter V. Mørch
There is a way to comment... if you read the very thread you linked to.
Jimmy Cuadra
Could you please let me know how? Remember, I have a reputation of 1 at the moment... I've read the thread again, and can't find the answer given my reputation.
Peter V. Mørch