html - Flex 重叠 2 个子 flex 布局类连续设置

标签 html css reactjs flexbox

我有 2 个 css 类 leftColumn 和 rightColumn 排列在 React SPA 的行布局中。问题在于,当浏览器变窄时,rightColumn 会在 leftColumn“下方”,从而遮盖了其中的元素。

左列覆盖右列

leftColumn overlaying 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%;
}

Ant 想法如何解决这个问题?我已经尝试了很多 flex 设置的组合,但没有任何影响。

我需要的是让 leftColumn 和 rightColumn 随浏览器窗口缩小宽度而缩小宽度,每个都缩小到最小尺寸,然后让每个都获得水平滚动条

最佳答案

flex-wrap 是你需要的,尝试将它设置为 nowrap。

.allWrap {
    display: flex;
    flex: 1;
    flex-direction: row;
    align-items: flex-start;
    min-width: 830px;

    justify-content: space-around;
    overflow: hidden;
    flex-wrap: nowrap;

}

关于html - Flex 重叠 2 个子 flex 布局类连续设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56798586/

相关文章:

javascript - 具有交替滚动边的视差分屏

html - 如何使行水平保持在同一行?

javascript - 在 IE 中输入字段不显示光标或无法输入字母

html - 如何仅在一个方向上扩展表格行?

html - 为什么在父级大小不变的情况下向 div 添加内容会向页面添加滚动条?

html - 这个翻车是怎么回事?

javascript - 如何通过 react-bootstrap 在 DropdownButton 中包装太长的标题?

javascript - 在可变高度网格行中处理@material-ui骨架缩放的好方法?

javascript - 正则表达式帮助从react/jsx元素中获取className

javascript - 通过在 Javascript 中获取用户输入将文本替换为图像?