473,667 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

I have a "position:absol ute" 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:absol ute;top:10px;le ft:10px;width:4 00px;background-color:#eeeeff;}
#ContentBox {position:absol ute;top:10;left :10px;width:200 px;background-color:#eeffee;}
</style>

<div id="OuterBox">
<div id="ContentBox" >
<p>ContentBox<b r />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:visib le" for the outer DIV, but it didn’t
work.

Some help would be highly appreciated.
Jul 20 '05 #1
3 6943
/David Winter/:
<style type="text/css">
#OuterBox {position:absol ute;top:10px;le ft:10px;width:4 00px;background-color:#eeeeff;}
#ContentBox {position:absol ute;top:10;left :10px;width:200 px;background-color:#eeffee;}
</style>

<div id="OuterBox">
<div id="ContentBox" >
<p>ContentBox<b r />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
Jul 20 '05 #2
> 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:absol ute" 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:absol ute", 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?
Jul 20 '05 #3
/David Winter/:
I wasn't aware that "position:absol ute" 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>.
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:absol ute", right?
Depends.
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.
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>.<b r>...</div>
other content flows around<br>.<br> .<br>.<br>.<br >
.<br>.<br>.<br> .<br>...
</div>

Does it work for you?

--
Stanimir
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2047
by: Travis Spencer | last post by:
Hello, I am having some problem with a statically positioned element being obscured by one that is absolutely positioned. To see what I am working on, go to www.aracnet.com/~tspencer/misc/csspositioningproblem.html. The form element (colored yellow) is absolutely positioned relative to the DIV#Content element (colored silver). The form would obscure the text if it
4
2651
by: Christopher | last post by:
This should be a quick one. URL: http://cfa-www.harvard.edu/~cpilman/Stuff/flush.html Code: ============================= <!DOCTYPE HTML Public "-//W3C//DTD HTML 4.01//EN"> <HTML><Head><Title>Get my feet off the ground</Title> <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=us-ascii"> <Style type="text/css"> Body { font-size: 60px; }
7
4716
by: Jonas Smithson | last post by:
Hello all, I have an absolute positioned parent div, and nested inside it is an absolute positioned child div -- I mean the div *code* is nested inside, but the child is physically positioned so that it's completely outside the parent div (to the left of its parent, in a left-side margin area). The child div contains hyperlinks. Explorer 6 (on Windows) has no problem with this. However, in Netscape 6, the links are unclickable. I...
0
4512
by: Red | last post by:
See http://reenie.org/test9.php There are two examples each with three nested divs. The only difference between the two is that the first example has no padding in the inner div, the second has 10px padding in the inner div. The middle div has no padding and its black background should not show up at all.
5
2510
by: Benjamin Esham | last post by:
Hello all, I have a very wide image that I want positioned in the extreme top left of the page. If the browser window is too narrow to contain the whole thing, that's fine-- the image should just be cut off, with no horizontal scrollbar. If the browser window is wider than the image, then I'd like a gray region to the right of the image. (The right side of the image fades to gray, so the image will look okay even if the browser...
4
4573
by: mike eli | last post by:
Hi, I have several absolute positioned elements inside an absolute positioned DIV. I would like one of the nested elements to have a dynamic width. I set it's left and right attributes to 5, so the the element should have a width = parentWidth - 10; This is the desired behaviour, but it won't work. I still have to specify a width or the element has a width of 0. Setting the width to '100%' doesn't give me the desired effect; it takes...
3
1788
by: John A Grandy | last post by:
on my WebForm, Panel1 is positioned absolutely , with settings for Top , Left , Width , Height ... Panel1 contains various sub-panels: PanelA , PanelB , PanelC ... these sub-panels' content flows naturally ( PanelA 's content is immediately followed by PanelB 's content, etc. ) however , if i remove the final sub-panel ( PanelX ) from Panel1 and place it immediately following Panel1 , then PanelX 's content will appear at the
9
1856
by: MariusI | last post by:
Consider the following class layout public class Order { public ProductOrder AddProductOrder(/* variables required to create a product order */) { /* Check if the product order can be added to the order */ }
5
3990
by: felipevaldez | last post by:
how can I put an element below another element, that's not absolutely positioned? so I have a n element, called X, and next to that, an element Y X Y XXXXXX
0
8458
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8888
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8565
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7391
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.