469,609 Members | 1,705 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Wrapper div doesn't take into account rel pos of content div?

Seemingly simple problem. I have a wrapper div with a border. Inside
is a content div, which uses relative positioning to move it down a
bit from the top of the wrapper border -- I used positioning to avoid
the discrepancies between IE and Mozilla when it comes to
margins/padding. The problem is, now the content div breaks out of the
wrapper div -- the wrapper fails to grow to accomodate the positioned
content, and instead acts as though the content is still in its
default position. Is there a way to fix this?

Here's an example:

<style>
div.wrap{border:1px solid blue;width:300px;}
div.content{border:1px solid
black;position:relative;top:50px;left:50px;width:2 00px}
</style>
<html>
<body>
<div class=wrap>
<div class=content>
test<br>
test<br>
test<br>
</div>
</div>
Jul 20 '05 #1
1 1750
Lister Monocle wrote:
I have a wrapper div with a border. Inside is a content div, which
uses relative positioning to move it down a bit from the top of the
wrapper border -- I used positioning to avoid the discrepancies
between IE and Mozilla when it comes to margins/padding.
You'd be better off accepting that there might be differences in margins
in different browsers.
The problem is, now the content div breaks out of the wrapper div --
the wrapper fails to grow to accomodate the positioned content, and
instead acts as though the content is still in its default position.
That sounds like correct behavior, unless I'm missing something.
Position: relative means adjust the position of that element without
reflowing the page.
Is there a way to fix this?
Since nothing is broken, no. You need margins here. If you're having
trouble with that, reply here with details.

Here's an example:

[snip]

Please provide a url, not pasted-in code. Preferably a simplified test
case. With valid code.

--
Brian (remove "invalid" to email me)
http://www.tsmchughs.com/
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Steve Richfield | last post: by
4 posts views Thread by Gary Bond | last post: by
22 posts views Thread by linwu02 | last post: by
7 posts views Thread by Justin Koivisto | last post: by
2 posts views Thread by GinTon | last post: by
5 posts views Thread by Bob Imperial | last post: by
3 posts views Thread by =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.