473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

position:absolute relative to parent or to window?

Hello,

as I understand the specs http://www.w3.org/TR/CSS21/visuren.html#x19 an
absolute positioned block element is positioned relative to its parent
element. This is told in the german selfhtml reference, too:
http://de.selfhtml.org/navigation/cs...positionierung

In fact firefox and konqueror do position the block relativ to the window
border. This is explained here, too:
http://www.w3schools.com/dhtml/dhtml_css.asp

Which behaviour is correct?

Here is an example:

<html>
<head>
<style type="text/css">
#header { height: 44px;
border: 1px solid black;}

#copyright { border: 1px solid green;
position: absolute;
right: 12px;
bottom: 0px; }

</style>
</head>

<body>
<div id="header">
<div id="copyright">
blah foo text
</div>
</div>
</body>
</html>

--
Jul 27 '05 #1
6 18805
Gert Brinkmann wrote:
as I understand the specs http://www.w3.org/TR/CSS21/visuren.html#x19 an
absolute positioned block element is positioned relative to its parent
element.
No, to its containing block, which is defined as the nearest ancestor
element which has a position property with a value other than "static". If
there is no such element then it is from the edges of the viewport.
In fact firefox and konqueror do position the block relativ to the window
border.
Only if there isn't a containing block ... and you don't have any toolbars
or menu bars in your window.
This is explained here, too:
http://www.w3schools.com/dhtml/dhtml_css.asp


W3Schools - wrong again.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 27 '05 #2
David Dorward wrote:
Gert Brinkmann wrote:
as I understand the specs http://www.w3.org/TR/CSS21/visuren.html#x19 an
absolute positioned block element is positioned relative to its parent
element.


No, to its containing block, which is defined as the nearest ancestor
element which has a position property with a value other than "static". If
there is no such element then it is from the edges of the viewport.


Thank you very much for your answer. It's unbelievable, but it is true. This
is the way, firefox behaves (I did not check other browsers). Hmm, does
this behaviour make sense? But ok, this is not the question here.

Thanks again,

Gert

Jul 28 '05 #3
>>
No, to its containing block, which is defined as the nearest ancestor
element which has a position property with a value other than "static". If
there is no such element then it is from the edges of the viewport.


Thank you very much for your answer. It's unbelievable, but it is true. [...]

Why is it unbelievable? It provides a way to position:absolute in any
containing block.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Jul 28 '05 #4
Jim Moe wrote:
Why is it unbelievable? It provides a way to position:absolute in any
containing block.


Certainly yes, but IMHO it is not very intuitive. If you lay out a DIV
containing a lot of styled HTML, I do not like that the content changes
layout if you change the placing of the DIV. But perhaps I first have to
internalise(?) this technique.

Gert

Jul 29 '05 #5
Gert Brinkmann wrote :
David Dorward wrote:

Gert Brinkmann wrote:

as I understand the specs http://www.w3.org/TR/CSS21/visuren.html#x19 an
absolute positioned block element is positioned relative to its parent
element.


No, to its containing block, which is defined as the nearest ancestor
element which has a position property with a value other than "static". If
there is no such element then it is from the edges of the viewport.

Thank you very much for your answer. It's unbelievable, but it is true. This
is the way, firefox behaves (I did not check other browsers). Hmm, does
this behaviour make sense? But ok, this is not the question here.

Thanks again,

Gert


I personally reported this bug at Opera some 30 months ago when Opera
7.0 beta 1 came out. I also reported the problem, that precise bug to
MSIE 7 dev. team too.

"percentage width value on absolutely positioned elements should
calculate the %tage of the containing block, not %tage of the immediate
parent node of the abs. pos. elements. Safari 1.x and Mozilla-based
browsers supports this correctly (...)"
http://channel9.msdn.com/wiki/defaul...rSupportforCSS

FYI, Opera 6.06 did not have that bug: it was positioning an abs. pos.
element regarding its positioned ancestor otherwise relative to the
viewport dimension.

Gérard
--
remove blah to email me
Jul 29 '05 #6
Gert Brinkmann wrote:
Jim Moe wrote:
Why is it unbelievable? It provides a way to position:absolute in any
containing block.


Certainly yes, but IMHO it is not very intuitive. If you lay out a DIV
containing a lot of styled HTML, I do not like that the content changes
layout if you change the placing of the DIV. But perhaps I first have to
internalise(?) this technique.


See it this way:

If you have

<div class="a">
..
<div class="b">..</div>
..
</div>

and div.b should be positioned relative to div.a, you don't want the layout
to change, if you insert (for semantic reasons) another level inbetween:

<div class="a">
..
<div>
<div class="b">..</div>
</div>
..
</div>

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Jul 29 '05 #7

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

Similar topics

0
by: Mike | last post by:
I've been working on a pop-up menu, one of those where you mouse over a button and a submenu pops up. Because the client wanted the menu centered, I gave the starting point of the submenu an...
3
by: Alexander Fischer | last post by:
Hello everybody, can someone help me with this problem: I'm creating a page with a sidebar, and I wanted to create the sidebar as a div which gets a "position:absolute". The problem: if the...
6
by: Harald Kirsch | last post by:
In the W3C document about CSS2, I read at http://www.w3.org/TR/REC-CSS2/visuren.html#choose-position the following: absolute The box's position (and possibly size) is specified with the...
3
by: Markus Ernst | last post by:
Hello Reading the follwing document: http://www.w3.org/TR/WD-positioning-970131#In-flow it seems very clear that position:relative should be relative to the parent element. So in the following...
4
by: Peter Pfannenschmid | last post by:
Hello experts, I would be very grateful if you would have a look at the following URL: http://www.omeganet.de/test.html The html file and the associated style have been validated...
2
by: Joachim Bauer | last post by:
I'm using the code below to display a menu that opens when the mouse goes over the main menu item (try it in your browser to understand the behaviour). It uses "position:absolute" and a switch...
6
by: alex | last post by:
I'm playing around with css popups a la http://www.meyerweb.com/eric/css/edge/popups/demo.html for here: http://www.redbrick.dcu.ie/~alex/golf/courseinfo.html (css)...
19
by: derelicten | last post by:
hello , I have an issue positionating some pics I want to anchor to an existing table cell but I cant just place regular position on the cell because the background is fixed height and the set of...
6
by: ThunderMusic | last post by:
Hi, I think the subject says it all... thanks ThunderMusic
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...

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.