Jump to content

Auto width sizing divs.. Sorry!


shelluk

Recommended Posts

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 :)

 

Link to comment
Share on other sites

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  |
|__________|_____|_____________________________|

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.