tags:

views:

418

answers:

5
A: 

The problem lies in your left div where you state "width can increase depending on the content". How is this width defined? The div to the right can expand to 100% of the remaining space but you must define the relationship between the left and the right divs by either providing a fixed width to the left div or providing a percentage to both that equals 100%.

Michael Glenn
I think you're just restating his problem. What he wants to know is how to make sure the second div takes up 100% of the space, given that the first div has sized itself based on its content; however it does that is not part of the problem
Ed Marty
the left div will be a counter with customized fonts, css sprites, and deppending on the number, it will increase its width...
Paulo
A: 

Well, as you’ve probably seen, so.com used fixed width div’s to achieve your layout goal.

Obviously my first tries setting the width automatically failed, but maybe I’ve a useful workaround for you: use left and right floating of both boxes.

<div style="border: 1px solid #000000; width: 60%">
  <div style="border: 1px solid #444444; float: left;">
    some text
  </div>
  <div style="border: 1px solid #999999; float: right;">
    foo
  </div>
</div>

Of course this will only help if I understood your question correctly ;)

Gerhard Dinhof
+1  A: 

You could try the following:

<style type="text/css">
 #container {
  width:60%;
 }

 #content {
  width:100%;
 }

 #user-content {
  float:left;
 }
</style>

<div id="container">
 <div id="content">
  <div id="user-content">
   <p>This can change depending on what is in here.</p>
  </div>
  <!-- The rest of the page's content goes here. -->
 </div>
</div>

This makes the "content" div fill the rest of the space that "user-content" doesn't fill. It will only be an issue when your content is taller than the user content... but that's a different problem :)

This is another possiblity:

<style type="text/css">
 #container {
  width:60%;
 }

 #content {
  width:100%;
  float:left;
 }

 #user-content {
  float:left;
 }

 #page-content {
  float:left;
 }
</style>

<div id="container">
 <div id="content">
  <div id="user-content">
   <p>This can change depending on what is in here.</p>
  </div>
  <div id="page-content">
   <p>This should take up the rest of the space.</p>
  </div>
 </div>
</div>
Zack Mulgrew
This one works good! thanks, one more question... how could I place more tags inside page-content and make them float on the right? and always stay on the right?
Paulo
If you just want artibrary elements to be positioned on the right of the page-content div you can simply add float:right; to their style attribute or create a class and assign it to them. If you are trying to create a three-column layout there is a different solution.
Zack Mulgrew
A: 

As far as I know the only way to give your variable width container a variable width and float it to the left is to give it {width:auto;float:left;}

But I don't know if you can do anything useful with this because if you have text or a lot of small fixed width items to put in this container, they will keep expanding out along the first line until they've filled the width of the outer div before going on to the second line. They won't fill up the whole height and then push outward gradually as the text gets too much to contain.

wheresrhys
A: 

Just a thought - you might be able to do some nifty JavaScript (possibly using jQuery?) which sizes those divs like you need them.

Brandon Montgomery