/    Sign up×
Community /Pin to ProfileBookmark

div vertical grow

Hi, I have a question about properly setting up a vertical grow of an outer div.
What I try to do is to have two divs, left and right, if one div grows, the outer div grows with it as well.

Ths markup below works as I wanted in IE 6 and IE 7, to my surprise. But it doesn’t work in FF, Safari and IE 8 beta.
<!– the outer div –>
<div style=”width:500px; border: 1px solid red”>

<!– inner left div –>
<div style=”float: left; width: 49%; margin: 0; text-align: justify; border: 1px solid blue;”>
BLAH!<br/>BLAH!<br/>
</div>
<!– inner right div –>
<div style=”float: right; width: 49%; margin: 0; border: 1px solid green”>
BLAH!<br/>BLAH!<br/>
</div>

</div> <!– end of outer div –>

However, if I add “float: left” to the outer div like this:

<!– the outer div –>
<div style=”[COLOR=”Red”]float: left; [/COLOR]width:500px; border: 1px solid red”>

<!– inner left div –>
<div style=”float: left; width: 49%; margin: 0; text-align: justify; border: 1px solid blue;”>
BLAH!<br/>BLAH!<br/>
</div>
<!– inner right div –>
<div style=”float: right; width: 49%; margin: 0; border: 1px solid green”>
BLAH!<br/>BLAH!<br/>
</div>

</div> <!– end of outer div –>

Then it works as I want. Even tho it works, I still find this awkward. And the fact that the first method doesn’t work on the standard but on the IE 6 and 7, leads me to think that I did something wrong. I wonder what is the proper way to do it?

Thanks

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@CentauriMay 24.2008 — [CODE]<!-- the outer div -->
<div style="[COLOR="Red"]overflow: hidden[/COLOR]; width:500px; border: 1px solid red">[/CODE]
is another way to clear floats.

To elaborate, a container normally should not surround floats, unless the floats are 'cleared", either by the overflow method, the container float method, or by an additional clearing element following the floats. IE will incorrectly surround floats when the container has "HasLayout" triggered, usually from the assignment of a dimension (in this case the width).
Copy linkTweet thisAlerts:
@MacPCauthorMay 24.2008 — Damn, I knew it was something dumb I did. Duh! :o

Thanks for the quick reply. ?
×

Success!

Help @MacPC spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...