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>
JamesTBennett
  • 2,091
  • 6
  • 19
  • 22

1 Answers1

1

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
  • 18,104
  • 8
  • 63
  • 81
  • cool this looks like it'll work. Thanks for the help. Why is everything in HTML a hack at best? – JamesTBennett Jun 24 '10 at 00:01
  • @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 Jun 24 '10 at 00:04
  • well in seems to work on it's own but when I use it in my project it breaks. – JamesTBennett Jun 24 '10 at 00:24
  • 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 M8R-yusfsn@mailinator.com if you want IM help – Jamie Wong Jun 24 '10 at 00:33