简体   繁体   English

HTML绝对位置会为其子级创建新的定位系统吗?

[英]HTML does absolute position create new positioning system for its children?

  1. as far as i know, absolute positioned element (.egspan style="position:absolute") will position based on its ancestor's position context, but this absolute positioned element WILL NOT create a new positioning system for its children, is that right????? 据我所知,绝对定位元素(.egspan style =“ position:absolute”)将基于其祖先的位置上下文进行定位,但是这个绝对定位元素不会为其子代创建新的定位系统,对吗? ???

  2. if #1 is correct, can someone tell me why parent is allowed to set to absolute position in this document? 如果#1是正确的,有人可以告诉我为什么允许父母在这份文件中设定绝对位置吗? (just search exactly this line in quote will bring you to the relevant paragraph "Specify the parent container as position:relative or position:absolute." http://phrogz.net/css/vertical-align/index.html (只要精确地搜索引号中的这一行,您就会进入相关段落“将父容器指定为position:relative或position:absolute。” http://phrogz.net/css/vertical-align/index.html

parent in that link must be 'relative' right, but not absolute, why does it say absolute is ok? 该链接中的父级必须“相对”正确,但不是绝对正确,为什么它说绝对可以? because only relative creates new positioning context, so in that link bullet #3, the top 50% should not work 因为只有亲戚会创建新的定位环境,所以在该链接项目3中,排名前50%的用户不应工作

(1) is not correct. (1) 正确。 Elements with positioning defined will be positioned relative to the nearest ascestor that has its position set to anything other than static (the defautl). 定义了定位的元素将相对于其位置设置为静态(默认值)以外的其他最接近的祖先进行定位。

from: http://www.w3.org/TR/CSS2/visuren.html#absolute-positioning : 来自: http : //www.w3.org/TR/CSS2/visuren.html#absolute-positioning

In the absolute positioning model, a box is explicitly offset with respect to its containing block. 在绝对定位模型中,框相对于其包含的块显式偏移。 .... An absolutely positioned box establishes a new containing block for normal flow children and absolutely (but not fixed) positioned descendants ....绝对定位的框为正常流动的子代和绝对(但不固定)定位的后代建立了新的容纳块

Note also: relatively and fixed positioned elements also establish new containing blocks for absolutely positioned elements. 另请注意:相对和固定位置的元素还会为绝对位置的元素建立新的包含块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM