shelluk Posted June 25, 2008 Share Posted June 25, 2008 Has any one managed to come up with some way of doing the following? Divs below each other with the width sized to the test with in. __________ | | | blah | |__________| ___________________________________ | | | blah blah blah blah blah blah | |___________________________________| ____________________ | | | blah blah blah | |___________________| I'm getting it all on top of each other though using the following code though (IE6 and FF3). <html> <head> <title>Test</title> <style type="text/css"> div { position: absolute; background-color: #EEEEEE; width: auto; padding: 20px; border: solid 1px black; } </style> </head> <body> <div> this is a line of text this is a line of text this is a line of text this is a line of text </div> <div> this is line 2 </div> <div> line 3 </div> </body> </html> It does seem may be one of those never ending no "one" answer questions. A lot of the forum posts I found in google though are all rather old as well. Any ideas? Thanks, Shell Quote Link to comment https://forums.phpfreaks.com/topic/111825-auto-width-sizing-divs-sorry/ Share on other sites More sharing options...
shelluk Posted June 25, 2008 Author Share Posted June 25, 2008 BTW. Realised it was clear by what I mean when I say "they appear on top". Like this: __________ _____ _____________________________ | | | | | line 3 |e 2 |text this is a line of text | |__________|_____|_____________________________| Quote Link to comment https://forums.phpfreaks.com/topic/111825-auto-width-sizing-divs-sorry/#findComment-574040 Share on other sites More sharing options...
haku Posted June 26, 2008 Share Posted June 26, 2008 Divs below each other with the width sized to the test with in. What? ------------------------- Take out 'position: absolute', and that may solve your problem. Although truth be told, I'm not sure what your problem is because of the sentence I quoted above. Quote Link to comment https://forums.phpfreaks.com/topic/111825-auto-width-sizing-divs-sorry/#findComment-574674 Share on other sites More sharing options...
dannyb785 Posted June 26, 2008 Share Posted June 26, 2008 Yea, get rid of position:absolute; and to space the divs apart, use "margin-bottom:10px" or however many px you want them apart. Oh and I dont think width: auto does anything. But I could be wrong. Quote Link to comment https://forums.phpfreaks.com/topic/111825-auto-width-sizing-divs-sorry/#findComment-574698 Share on other sites More sharing options...
haku Posted June 26, 2008 Share Posted June 26, 2008 It's valid CSS, but since it's the default, usually it won't do anything. The only time it will really do something is if you are inheriting a set width for some reason, and want to set the width to not be static for that element alone. Quote Link to comment https://forums.phpfreaks.com/topic/111825-auto-width-sizing-divs-sorry/#findComment-574718 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.