Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 23326
  • Total topics 4050
  • Total members 5576
  • Our newest member
    feha

TOP POSTERS

Horizontal Div Stretch

All problems and developments related to (X)HTML-markup and stylesheets are discussed and resolved here.
   

Horizontal Div Stretch

Postby dnpayne » Tue Oct 20, 2009 3:34 pm

Hey all, I have a container div, with 3 floated div's (left, middle, right) within the container div. I want the middle div to size horizontally based on the content. However, when I try (width: 100%) it takes on the parent div size. I have text that will change in the middle div. Some will be long and some short, so I need it to adjust depending on whats displayed.

Anyone know how to accomplish this?

Thanks.
User avatar
dnpayne
Smashing <hr />
 
Posts: 71
Joined: Wed May 20, 2009 12:19 pm
Location: Southern Indiana
   

   

Re: Horizontal Div Stretch

Postby jarek » Tue Oct 20, 2009 6:01 pm

Check this out:

Code: Select all
<div id="container" style="overflow: hidden;">
<div id="left" style="float: left; background-color: #555555; width: 25%; ">left data</div>
<div id="middle" style="float: left; background-color: #f5f5f5;">middle data middle data middle data</div>
<div id="right" style="float: left; background-color: #ff0000; width: 25%;">right data</div>
</div>


If it isn't that what you want please paste here you html and css code.
Front-end web developer with an admixture of web designer.
http://jarek.olsztyn.pl
User avatar
jarek
Smashing <frame>
 
Posts: 12
Joined: Sun Oct 18, 2009 8:14 am
Location: Poland
   

   

Re: Horizontal Div Stretch

Postby Andy » Tue Oct 20, 2009 6:07 pm

You could just float two of them (left and right) then make the middle one stretch 100%. Then you account for the floated images by adding margins to the middle one.
Andy
Smashing <h5>
 
Posts: 1025
Joined: Tue Sep 30, 2008 6:42 pm
Location: Sweden
   


Return to CSS and (X)HTML



Who is online

Users browsing this forum: No registered users and 1 guest