【发布时间】:2019-11-09 22:06:36
【问题描述】:
我有 2 个 css 类 leftColumn 广告 rightColumn 排列在一个 React SPA 的行布局中。问题是,当浏览器变窄时,rightColumn 会在 leftColumn 的“下方”隐藏其中的元素。
leftColumn 覆盖 rightColumn
代码如下:
<div className="allWrap">
<div className="leftColumn" style={{ height: this.height }}>
<div>
<DragLayer snapToGrid={false}/>
{/* objects to drag from */}
<div className="heading">Drag into the tree below to add item</div>
...etc
</div>
<div className="rightColumn">
<div className="banner" style={{ minWidth: '570px' }}>
<img
style={{ alignSelf: 'center' }}
src={require('../../Assets/logo_1080x361 copy.svg')}
alt={"Logo"}
/>
</div>
<div className="view" style={{ padding: '0px', flex: 1, minWidth: '570px' }}>
{/* the main view component, we pass clicked element and its content from the state */}
<ComponentView/>
</div>
</div>
css 类如下所示:
.allWrap {
display: flex;
flex: 1;
flex-direction: row;
align-items: flex-start;
min-width: 830px;
justify-content: space-around;
overflow: hidden;
}
.leftColumn {
flex: 1 1 25%;
display: flex;
position: fixed;
left: 0;
top: 0;
justify-content: flex-start;
flex-direction: column;
font-size: 0.9em !important;
width: 20%;
min-width: 270px;
background-color: rgb(248, 248, 248);
}
.rightColumn {
flex: 3 1 75%;
display: flex;
flex-direction: column;
justify-content: center;
width: 80%;
min-width: 560px;
margin-left: 20%;
}
蚂蚁知道我该如何解决这个问题?我已经尝试了许多 flex 设置的组合而没有任何影响。
我需要让leftColumn和rightColumn随着浏览器窗口宽度的减小而缩小宽度,每个都缩小到最小尺寸,然后让每个都有水平滚动条
【问题讨论】:
-
你试过 flex-wrap: wrap; 吗?
-
也许这不是你想要的,还有 flex-shrink 和 flex-grow 可能会有所帮助
-
@Jay 你可以清楚地看到我有完整的 flex 指令,包括 flex-shrink 和 flex-grow,请参阅 flex 文档以了解。