html - Flex-direction:反向列隐藏导航组件
问题描述
问题: 使用时<Navigation/>
组件消失flex-direction: column-reverse
但是,当我使用 时flex-direction: column
,组件呈现在屏幕顶部并且是可见的。
我的目标是将我的<Navigation/>
组件呈现为底部导航栏,类似于 iPhone 应用程序。
这是我的代码:
<div className="app">
<Router>
<div className="navigation__wrapper">
<Navigation />
</div>
<div className="route__wrapper">
<AppWrapper>
<Switch>
<Route
exact
path="/"
render={() => (
<MainLayout>
<Homepage />
</MainLayout>
)}
/>
</Switch>
</AppWrapper>
</div>
</Router>
</div>
这是我的CSS:
.app {
-ms-overflow-style: none;
scrollbar-width: none;
background-color: var(--main-background);
font-family: "Poppins";
max-width: 100vw;
min-width: 100vh;
display: flex;
flex-direction: column-reverse;
}
解决方案
Flex-direction:column-reverse 不仅会反转列的顺序,还会反转排列。例如,如果 align-items 和 justify-content 都设置为 flex-start(它们的初始值也是如此)并且您的 flex 项目的组合高度没有至少与 flexbox 容器一样大,它们都会移动到左下角而不是像您预期的那样停留在左上角。你可以像下面这样解决这个问题......
.app {
-ms-overflow-style: none;
scrollbar-width: none;
background-color: var(--main-background);
font-family: "Poppins";
max-width: 100vw;
min-width: 100vh;
display: flex;
flex-direction: column-reverse;
align-items: flex-start;
justify-content: flex-end;
}
或者,您可以只保留 flex-direction: 列并将按住导航的 div 向下移动到 route__wrapper 下方。
不是在这里推销自己,而是我制作了一个 Web 应用程序,可以帮助您理解 Flexbox。链接:https ://csspressme.web.app/playbox/flexbox
另外,我不确定这是否会完全帮助您而无需查看您的所有代码。
推荐阅读
- aws-device-farm - AWS Device Farm 文件上传 5MB 限制
- oracle - 西班牙语的 UTL_FILE 和字符集
- pine-script - pine-script,log(pi * (atr(factor)) 的含义是什么
- r - R中的ggplot - 具有两个y轴的直方图和线图
- php - 我无法使用其他计算机(相同的 wifi)在 xampp 中访问我的网站
- c# - 如果之前抛出,如何验证方法已达到
- swift - 使用 AVAudioplayer 展开可选值错误时意外发现 nil
- javascript - 联系表格 7 - 重定向到另一个页面
- java - json-b 是否有像 @JsonValue 一样工作的注释
- netsuite - 具有 GL 影响的库存调整脚本