tags:

views:

22

answers:

1

I want the right div to have a fixed width and the left div to take up everything else inside the box.

<div id='outer' style='width:100%'>
 <div id='inner1'></div>
 <div id='inner2'></div>
</div>
+1  A: 

There may be a better way of doing this, but this may achieve what you're trying to accomplish:

#outer {
  background-color: red;
}

.clear {
  clear:both;
}

#inner1 {
  background-color: red;
  margin-right:200px;
  float:left;
}

#inner2 {
  float: right;
  width: 200px;
  margin-left: -200px;
  background-color: blue;
}

Combined with

<div id='outer' style='width:100%'>
 <div id='inner1'>Foo</div>
 <div id='inner2'>Bar</div>
 <div class='clear'></div>
</div>

So, while this doesn't actually make the one on the left take up the rest of the space, it won't encroach upon the right column.

Associated jsFiddle:

Jamie Wong
cool this looks like it'll work. Thanks for the help. Why is everything in HTML a hack at best?
creocare
@creocare Everything is hackish because it's insanely difficult to accommodate what everyone wants to do with it. Also, what you're trying to do will be easy in CSS3: http://www.w3.org/TR/css3-values/#calc
Jamie Wong
well in seems to work on it's own but when I use it in my project it breaks.
creocare
If you can provide more details about it breaking, I might be able to help. Either post it here, or you can contact me at [email protected] if you want IM help
Jamie Wong