如果元素的位置是绝对的,浏览器是否会渲染回流?
如果我有一个具有绝对位置的元素,并且更改其左侧和顶部位置,则会回流到其父子元素吗?如果它自己的孩子不受影响,因为它们也是由左轴和上轴绝对定位的,那么它们又怎么样呢?
如果我更改元素的宽度/高度但在父元素及其子元素中不重要?
If I have an element with an absolute position and I change its left and top position will reflow to its parent children? And what about its own children if they are not affected as they are also absolute positioned by left and top axis?
If I change an element's width/height but have no importance in the parent and in its children?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
具有绝对位置的对象不会影响页面的布局。页面的布局不考虑绝对定位的对象。移动绝对定位的对象不会导致其他对象的任何回流。
使用绝对定位移动对象将导致其子对象随之移动。它不会回流它们,它们只会与父容器一起移动。
An object with absolute position does not affect the layout of the page. The page is laid out without regard for an absolute positioned object. Moving the absolute positioned object does not cause any reflow of other objects.
Moving an object with absolute positioning will cause its child objects to move along with it. It will not reflow them, they will just move along with their parent container.
对于具有绝对位置的元素,它不应该影响文档流,因此它的位置变化不应该导致页面dom树的回流(relayout),但是如果你测试 这个简单的案例,我们可以看到它确实在很短的时间内导致了重新布局(整个文档)。可能渲染引擎没有将其作为特殊情况处理。
For element with absolute position, it should not affect document flow, and so it's position change should not lead to reflow(relayout) of the page's dom tree, but if you test this simple case with Chrome DevTools, we can see it really causes relayout(the whole document) though in very short time. Probably the render engine didn't deal with it as a special case.