css绝对定位absolute

作者:大地Dudy
链接:http://www.zhihu.com/question/19926700/answer/63412898
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

绝对定位的盒子是相对于离它最近的一个已定位(fixed/relative/absolute)的盒子进行定位的。这其实是包含块的知识点,标准描述如下:
If the element has 'position: absolute', the containing block is established by the nearest ancestor with a 'position' of 'absolute', 'relative' or 'fixed', in the following way:
  1. In the case that the ancestor is an inline element, the containing block is the bounding box around the padding boxes of the first and the last inline boxes generated for that element. In CSS 2.1, if the inline element is split across multiple lines, the containing block is undefined.
  2. Otherwise, the containing block is formed by the padding edge of the ancestor.
原文地址:https://www.cnblogs.com/liujufu/p/5675963.html