HighDots Forums  

Outer DIV should encompass (absolutely positioned) inner DIV: How? :/

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Outer DIV should encompass (absolutely positioned) inner DIV: How? :/ in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Outer DIV should encompass (absolutely positioned) inner DIV: How? :/ - 06-05-2004 , 01:38 PM






This is probably trivial, but I simply don't get it.

I have a "position:absolute" type DIV with another one in it. I want
the outer DIV to encompass the inner one. I.e., when the inner DIV
contains text and images, the outer DIV should grow (vertically), so
that its background color and frame encompasses the inner DIV and all
its content.

Currently, when I do this:

<style type="text/css">
#OuterBox {position:absolute;top:10px;left:10px;width:400px; background-color:#eeeeff;}
#ContentBox {position:absolute;top:10;left:10px;width:200px;ba ckground-color:#eeffee;}
</style>

<div id="OuterBox">
<div id="ContentBox">
<p>ContentBox<br />1<br />2<br />3<br />4<br />5 etc.</p>
</div>
</div>


.... "ContentBox" starts where I want it to, but *overlaps* OuterBox
instead of filling it.

I tried "overflow:visible" for the outer DIV, but it didn’t
work.

Some help would be highly appreciated.

Reply With Quote
  #2  
Old   
Stanimir Stamenkov
 
Posts: n/a

Default Re: Outer DIV should encompass (absolutely positioned) inner DIV: - 06-05-2004 , 02:03 PM






/David Winter/:

Quote:
style type="text/css"
#OuterBox {position:absolute;top:10px;left:10px;width:400px; background-color:#eeeeff;}
#ContentBox {position:absolute;top:10;left:10px;width:200px;ba ckground-color:#eeffee;}
/style

div id="OuterBox"
div id="ContentBox"
p>ContentBox<br />1<br />2<br />3<br />4<br />5 etc.</p
/div
/div

... "ContentBox" starts where I want it to, but *overlaps* OuterBox
instead of filling it.
That's because your "ContentBox" is absolutely positioned and is
taken out of the content flow of the "OuterBox". Just change the
"ContentBox" style:

#ContentBox {
margin-top: 10px;
margin-left: 10px;
width: 200px;
background-color: #eeffee;
}

--
Stanimir


Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Outer DIV should encompass (absolutely positioned) inner DIV: How? :/ - 06-07-2004 , 05:22 AM



Quote:
That's because your "ContentBox" is absolutely positioned and
is taken out of the content flow of the "OuterBox".
I wasn’t aware that "position:absolute" puts an element out of
the content flow with regards to its *size*.

Let’s assume I want to give an element a fixed starting position
relative to its parent element. It should keep that position - no
matter what other elements follow/precede. In this case, I need
"position:absolute", right? And this means that the parent and other
child elements of the same parent will be positioned as if the
absolutely positioned DIV weren’t there at all?

So there is no way to give an element a fixed, unchangeable starting
position and still have other elements flow around it?


Reply With Quote
  #4  
Old   
Stanimir Stamenkov
 
Posts: n/a

Default Re: Outer DIV should encompass (absolutely positioned) inner DIV: - 06-07-2004 , 07:09 AM



/David Winter/:

Quote:
I wasn't aware that "position:absolute" puts an element out of
the content flow with regards to its *size*.
If an element is out of the flow how its size should impact the
flow? If the element still has impact on the flow then it is not
taken out of the flow.

Just read the CSS2 spec - its "Visual formatting model"
<http://www.w3.org/TR/CSS21/visuren.html>.

Quote:
Let's assume I want to give an element a fixed starting position
relative to its parent element. It should keep that position - no
matter what other elements follow/precede. In this case, I need
"position:absolute", right?
Depends.

Quote:
And this means that the parent and other
child elements of the same parent will be positioned as if the
absolutely positioned DIV weren't there at all?
Yes.

Quote:
So there is no way to give an element a fixed, unchangeable starting
position and still have other elements flow around it?
I'm not sure what you're trying to accomplish but:

#parent {
border: 1px solid;
padding: 0.5em;
}
#fixed-start {
margin: 1em 1em 1em 2em;
border: 1px dashed;
padding: 0.5em;
float: left;
width: 7em;
}

<div id="parent">
<div id="fixed-start">bla-bla<br>.<br>.<br>...</div>
other content flows around<br>.<br>.<br>.<br>.<br>
.<br>.<br>.<br>.<br>...
</div>

Does it work for you?

--
Stanimir


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.