473,761 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

absolute positioning of nested divs

Hi,
I am trying to get two divs to align at the bottom of another div. As
they are nested in this div, I expected them to be positioned at the bottom
of it, using the code below, but they are instead at the bottom of the body.
note - I do want them on top of each other, so the only problem is - where
is the bottom, and how can I make it the same as the bottom of the div.

Thanks, Martin (code below)

<html>
<head>
<title>
test
</title>
</head>
<body>
<div style="height: 100px; border: 1px solid black">
<div style="position : absolute; bottom: 0px">skjfh</div>
<div style="position : absolute; bottom: 0px">flj</div>
</div>
</body>
</html>

--
Martin Eyles
ma**********@NO SPAM.bytronic.c om
Oct 25 '05 #1
4 4757
"Martin Eyles" <ma**********@N OSPAM.bytronic. com> wrote:
I am trying to get two divs to align at the bottom of another div. As
they are nested in this div, I expected them to be positioned at the bottom
of it, using the code below, but they are instead at the bottom of the body.
note - I do want them on top of each other, so the only problem is - where
is the bottom, and how can I make it the same as the bottom of the div.
http://www.w3.org/TR/CSS21/visudet.h...-block-details
(code below)


Don't post code to the group, upload a minimized test case using some
real content and post the url.

--
Spartanicus
Oct 25 '05 #2


"Spartanicu s" <in*****@invali d.invalid> wrote
"Martin Eyles" <ma**********@N OSPAM.bytronic. com> wrote:
I am trying to get two divs to align at the bottom of another div. As
they are nested in this div, I expected them to be positioned at the bottomof it, using the code below, but they are instead at the bottom of the body.note - I do want them on top of each other, so the only problem is - whereis the bottom, and how can I make it the same as the bottom of the div.


http://www.w3.org/TR/CSS21/visudet.h...-block-details


According to this link, the text should be at the bottom of the box with a
border, which is what I want, yet it is at the bottom of the page. This
problem occurs in both firefox and internet explorer. Ultimately, it really
only needs to work in ie, as it is for a closed web application, which
already uses activex (so is already ie only). Even so, I would prefer if
possible a fix that is standards compliant, as this will help in the future,
but if not possible, I'll take the hack.
(code below)


Don't post code to the group, upload a minimized test case using some
real content and post the url.


http://www.bytronic.com/tests/test1.html

I don't really have real content as such. It is for a web app rather than a
website as such, so I don't have masses of text. Anyway, real content would
kind of go against having a minimised test case.

Thanks for all your help,
Martin

--
Martin Eyles
ma**********@NO SPAM.bytronic.c om
Oct 25 '05 #3
"Martin Eyles" <ma**********@N OSPAM.bytronic. com> wrote:
> I am trying to get two divs to align at the bottom of another div. As
>they are nested in this div, I expected them to be positioned at thebottom >of it, using the code below, but they are instead at the bottom of thebody. >note - I do want them on top of each other, so the only problem is -where >is the bottom, and how can I make it the same as the bottom of the div.


http://www.w3.org/TR/CSS21/visudet.h...-block-details


According to this link, the text should be at the bottom of the box with a
border


No, I'll quote the most relevant bits: "If the element has 'position:
absolute', the containing block is established by the nearest ancestor
with a 'position' of 'absolute', 'relative' or 'fixed',"

[...]

"If there is no such ancestor, the containing block is the initial
containing block."
>(code below)


Don't post code to the group, upload a minimized test case using some
real content and post the url.


http://www.bytronic.com/tests/test1.html

I don't really have real content as such. It is for a web app rather than a
website as such, so I don't have masses of text. Anyway, real content would
kind of go against having a minimised test case.


Using real content allows us to see what you are actually trying to do,
often the perceived solution is wrong.

--
Spartanicus
Oct 25 '05 #4
Ah, sorry, missed that as it was quite subtle. So essentially, to get this
effect, whilst maintaing normal flow for the outer div, I need add
"position: relative" to the outer div style.

http://www.bytronic.com/tests/test2.html

it works now!

Thanks,
Martin

--
Martin Eyles
ma**********@NO SPAM.bytronic.c om

"Spartanicu s" <in*****@invali d.invalid> wrote in message
news:j9******** *************** *********@news. spartanicus.utv internet.ie...
"Martin Eyles" <ma**********@N OSPAM.bytronic. com> wrote:
> I am trying to get two divs to align at the bottom of another div. As >they are nested in this div, I expected them to be positioned at the

bottom
>of it, using the code below, but they are instead at the bottom of the

body.
>note - I do want them on top of each other, so the only problem is -

where
>is the bottom, and how can I make it the same as the bottom of the div.
http://www.w3.org/TR/CSS21/visudet.h...-block-details


According to this link, the text should be at the bottom of the box with a
border


No, I'll quote the most relevant bits: "If the element has 'position:
absolute', the containing block is established by the nearest ancestor
with a 'position' of 'absolute', 'relative' or 'fixed',"

[...]

"If there is no such ancestor, the containing block is the initial
containing block."
(code below)

Don't post code to the group, upload a minimized test case using some
real content and post the url.


http://www.bytronic.com/tests/test1.html

I don't really have real content as such. It is for a web app rather than awebsite as such, so I don't have masses of text. Anyway, real content wouldkind of go against having a minimised test case.


Using real content allows us to see what you are actually trying to do,
often the perceived solution is wrong.

--
Spartanicus

Oct 25 '05 #5

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

Similar topics

4
11019
by: Ken Kast | last post by:
Here's my situation. I have a statically positioned table that has an image in a cell. I also have some layers, defined by absolute-positioned DIVs for some animation. Everything works until I scroll/resize. Then the image "moves" on the screen but the animation doesn't. The net effect is that their relative positioning changes. I'd like to have it be that they would stay in the same relative position. I want to keep the image as an...
13
3049
by: murali | last post by:
Hello everyone, I used absolute positioning with div tag in my website. The page looks cool as long as someone doesn't try to zoom in by increasing the text size (ctrl++ or thru changing font size in browser settings). When someone does that, the layers seem to overlap and the layer with a greater z value pops in front and the other layers are pushed back. The most obvious solution will be to prevent the user from increasing the text...
5
5003
by: Duane Lambe | last post by:
On some suggestions from this group, I've started to turn my internal helpdesky site for our company to non-absolute positioning. I've been reading O'Reilly's CSS book, and several web sites and tips. For the most part, things are going OK, but I can't seem to find an answer to a particular problem. Using a simpler example, below's some stuff...what I'm trying to do, is get the DIVs inside the .mainbody DIV to be 100% of their parent's...
14
2480
by: Harlan Messinger | last post by:
What am I not understanding about the definition of { position: absolute; }? "The box's position (and possibly size) is specified with the 'left', 'right', 'top', and 'bottom' properties. These properties specify offsets with respect to the box's containing block." Please take a look at http://gavelcade.com/abspos.html and help me understand why my nested, absolutely positioned divs are being positioned with respect to the page rather...
4
3202
by: xtort | last post by:
My question is: If you create a template in Photoshop, slice it in ImageReady, using the CSS output option(under the "slices" menu in "output--options"), and then use the CSS output for a template(which will all be absolute-postioned DIVs)--would there be any foreseeable drawbacks to this? Put another (simpler) way: are there drawbacks to positioning everything on the page with absolute references alone?
4
25834
by: wls | last post by:
I've got a problem that requires rendering DIVs at different offset locations, and while I've got a solution that works, the absolute positioning is working to the client window, not to the parent container. The stuff I write will get placed inside a table cell produce by someone else's template -- I have no control other than to emit HTML/CSS within that sole cell. So, I decided to construct a simple case and am having problems...
1
1895
by: Siegfried Heintze | last post by:
I want to implement drag and drop for tables, divs, spans. The problem is that I don't know how wide or long my tables, divs and spans are going to be in advance so I cannot use absolute coordinates. (It always seemed odd to me that there is no function called GetExtent that would return the bounding rectangle of an object -- this would solve my problem). There is a way, however, to fetch the coordinates of an object (such as a table, or...
2
3164
by: nonsensitor | last post by:
I'm just learning xhtml & css, primarily from westciv's online tutorials and css guide. I've run into a couple of problems with a page I'm developing that I can't figure out. The first problem is that I would like to display some text on top of an image within the header. I've tried using absolute positioning to specify where the phone number should appear in relation to the parent div (#header). However the text appears to be positioned in...
14
3314
by: Fistro | last post by:
I'm trying to find a design that would allow me to build web pages without having to worry about compatibility issues (not too much, in any case,,,) I've came across this CSS layout technique: http://alistapart.com/articles/fauxabsolutepositioning It calculates the left offset from a fixed position, as opposed to calculating it from the right edge of the preceding element by using a combination of position: relative, left: 100% and a...
0
9353
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
10123
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...
0
9975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9909
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
9788
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8794
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...
1
7342
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5241
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
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.