html - 位置 CSS 属性影响其子级的方式是什么?
问题描述
我想让PaginationBar-Wrapper
and WriteButton-Wrapper
(两者都是 的子级Wrapper
)相对于父级的位置,但不会相互影响。在 StackOverflow 中阅读了这个问题后,我明白这position: absolute
可能是我的答案。
根据 MDN,位置是设置自身位置的属性,但是,我发现父级的位置属性会影响子级的情况。
在第一种情况下,它非常适合我。
.Wrapper {
position: relative;
flex-direction: row-reverse
}
.PaginationBar-Wrapper {
position: static;
}
.WriteButton-Wrapper {
position: absolute;
}
第二种情况,影响孩子身高
.Wrapper {
position: static;
flex-direction: row-reverse
}
.PaginationBar {
position: static;
}
.WriteButton {
position: absolute;
}
这两种情况有什么区别?位置属性影响其子级的方式是什么?
这是这些代码的 HTML 结构。
<div className="Wrapper">
<div className="PaginationBar-Wrapper">
<PaginationBar />
</div>
<div className="WriteButton-Wrapper">
<button className="write-button">작성하기</button>
</div>
</div>
解决方案
推荐阅读
- android - Android 数据绑定未正确更新视图
- apache-kafka - Kafka升级:升级时需要指定inter.broker.protocol.version吗?
- c# - Unity3D:如何在运行时仅显示两个网格之间的交集/横截面?
- c# - 使用 iText 7 创建的可见签名未在 chrome 中显示
- autohotkey - 如何调整作为参数传递的数组的索引?
- bots - 如何在电报机器人中每 1 行显示 1 个按钮?
- opencv - KAZE 和 AKAZE 中的八度音阶和子级别是什么?
- javascript - 来自restapi的图像/ png响应未显示在浏览器中
- python-3.x - asset_url_for() 在烧瓶饼干切割器(flask-webpack)中返回 None
- laravel - 当laravel中的条带支付错误时如何在try/catch中重定向