Link to home
Create AccountLog in
Avatar of John Carney
John CarneyFlag for United States of America

asked on

Giving a div an adjustable width.

Please take a look at this page: http://www.discretedata.com/JCPortfolio/testAuto.html

How do I style the container so that its width adjusts to the fixed size of the inner-container?

Thanks!

John
Avatar of Mark Steggles
Mark Steggles
Flag of United States of America image

Hello,

You cant make a div do that. Is the inner container always going to have that width? Cant you just give the outer container a width of say 640px

Thanks
Avatar of John Carney

ASKER

So you can do it with height but not width? I guess the only way to do it would be to make your container a one cell table. Is that considered to old-fashioned to do nowadays?

John
ASKER CERTIFIED SOLUTION
Avatar of Mark Steggles
Mark Steggles
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
*Unless a div is given a width it will always be as wide as it can be
I could write u a little javascript if u want
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Yes please, a javascript would be great!
I stumbled upon a stupidly simple solution that works in Firefox, Chrome and Safari, and almost works in Opera: give container the style "display:table" as Kravimir suggested, AND a width less than its child. (display:table alone doesn't work, at least not for me).
  Of course it doesn't work at all in IE, but it's very tantalizing, so I'm wondering if it triggers something in you that would be an all-purpose answer.  Here's what I mean: http://www.discretedata.com/JCPortfolio/testAuto2.html

Thanks,
John