html – 当我在子块中使用position:absolute时它不会引用父块?

前端之家收集整理的这篇文章主要介绍了html – 当我在子块中使用position:absolute时它不会引用父块?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_301_0@

参见英文答案 > Position absolute but relative to parent                                    4个
在HTML中,当您在子块中使用position:absolute css属性时,绝对值不会从它从整个浏览器窗口引用的父标记获取.
示例代码如下所示..

CSS

.parent {
    width: 400px;
    height: 400px;
    border: 1px solid green;
}

.child {
    position: absolute;
    width: 200px;
    height: 200px;
    border: 1px solid red;
    bottom: 0px;
}
最佳答案
如果你想在父块中安排子项,只需在父CSS中添加position:relative
原文链接:https://www.f2er.com/css/427607.html

猜你在找的CSS相关文章