【发布时间】:2021-03-03 15:27:28
【问题描述】:
我有.left-navbar 和.columns-wrapper,其中有两列.left-column 和.right-column。第一列和第二列有 50% 的 .columns-wrapper,直到我将 position: fixed 添加到 .right-column 和 .right-column 占用浏览器宽度的 50% 而不是 .columns-wrapper。
.page-wrapper {
width: 100vw;
height: 100%;
display: flex;
background: red;
}
.page-wrapper .left-navbar {
width: 88px;
height: 100%;
background: yellow;
}
.page-wrapper .columns-wrapper {
width: calc(100% - 88px);
height: 100%;
background: orange;
display: flex;
}
.page-wrapper .columns-wrapper .left-column {
width: 50%;
height: 100%;
background: red;
}
.page-wrapper .columns-wrapper .right-column {
width: 50%;
height: 100%;
background: green;
}
<div class="page-wrapper">
<div class="left-navbar">
</div>
<div class="columns-wrapper">
<div class="left-column"></div>
<div class="right-column"></div>
</div>
</div>
【问题讨论】:
-
拜托,你能编辑你的问题添加一个stackoverflow.com/help/minimal-reproducible-example(最小的可重复示例)
-
The fixed element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to the initial containing block established by the viewport来自MDN -
那么我应该改变什么