Forum Moderators: not2easy
Well, here's my first post ;)
I'm having some problems with getting the height of a div-element to collapse around two additional div's used as culumns. Therefore I have not specified the height of the main element, althought I specified the width.
I want these two additional div-elements to be inside the main one and create two columns. I also want the height of the tallest one in any given incident to define the height of the main div-element.
What is the best/correct way to do this?
Here's my best try and it just won't work:
#main {
background: red;
width: 400px;
}
#left {
background: blue;
width: 200px;
float: left;
}
#right {
background: green;
width: 200px;
float: left;
}
<div id="main">
<div id="left">
<p>blabla</p>
<p>blabla</p>
<p>blabla</p>
</div>
<div id="right">
<p>blabla</p>
<p>blabla</p>
</div>
</div>
The background colors are just used for graphic descriptions. As you can see the left column is supposed to be a little bit taller than the right one.
If you regard the background colors the result should of course look something like this:
<img src="http://example.com/lmk/description.GIF" width="223" height="55">
[edited by: SuzyUK at 2:24 pm (utc) on Jan. 27, 2006]
[edit reason] examplified URL [/edit]
Well, I had already tried that and it doesn't work either. But actually this makes the main element obtain the same height as the right element (whether I let it be the smallest or the tallest column), but as I mentioned before I'd like it to have the same height of whichever column that's tallest. In this case it's of course the left element. Still it doesn't seem to matter how tall I let the left be, the main element always obtains the height of the right one.
Before I specified a float on the main element it's height seemed to be 0.
I think we're really close to solving this, but I'm just not that familiar with the fundamentals of these div-elements :(
The main element now DO obtain the height of whichever column that's tallest, but it doesn't show until I open the page in a browser?
(seems to work fine in both IE and Firefox)
But in Dreamweaver it's still wrong! Is there a more correct way to do this, or is it just a rendering error in Dreamweaver only that I don't need to worry about?
+------------------------------+
¦`Blue `````````¦'Green '''''''¦
¦```````````````¦''''''''''''''¦
¦```````````````¦''''''''''''''¦
¦```````````````¦--------------+
¦```````````````¦.Red..........¦
¦```````````````¦..............¦
¦```````````````¦..............¦
+------------------------------+
That is, the red continues to the height of the #left, which happens to be taller. If I add content to #right to make it taller, then I see this:
+------------------------------+
¦`Blue `````````¦'Green '''''''¦
¦```````````````¦''''''''''''''¦
¦```````````````¦''''''''''''''¦
+---------------¦''''''''''''''¦
¦.Red...........¦''''''''''''''¦
¦...............¦''''''''''''''¦
¦...............¦''''''''''''''¦
+------------------------------+
Is that not what you are going for?
EDIT: We cross posted. :) Glad it's working. I'm not familiar with Dreamweaver, so I couldn't tell you how to get it to do what you want. Good luck though.
I'm sure it's just a minor rendering error in Dreamweaver. At least IE, Firefox and Opera render it correctly so it's probably nothing to worry about.
Well, thanks again for your help! This saved me a lot of time :)
The only way I'm able to make this work as descibed above, is to float the main element as well.
But the problem is that the main element is supposed to be centered #$%& ...and the only way I know to make that happen is to NOT having a float on it and a margin set to "auto".
And that throws me back to square one :(
Anybody have a solution for this?