html - Flexbox flex 属性似乎只适用于 Firefox,不适用于 Chrome 或 Edge
问题描述
我正在尝试将弹性项目设置到页面底部。我让它在 Firefox 中工作,flex: 1 1
但这在 Chrome 和 Edge 中没有效果。如下图所示,flex 项目在 Firefox 中位于页面底部,但在 Chrome 和 Edge 中,它下方有一个空隙。我希望 Chrome 和 Edge 对 flex 项具有与 Firefox 相同的效果。我确实尝试添加浏览器前缀,但它们没有改变任何东西。我将外部容器作为弹性盒,因此选取框组件是弹性项目。我在选取框组件内使用了一个网格。
应用程序.css
.container {
background-color: rgb(177, 202, 183);
min-height: 100vh;
display: flex;
flex-direction: column;
padding-left: 3em;
padding-right: 3em;
}
.layout {
height: 20vh;
margin: 20px 5%;
}
.navlinks {
display: flex;
flex-direction: column;
margin-top: .8em;
}
.navlinks__link {
color: #fff;
text-decoration: none;
font-family: Helvetica, sans-serif;
font-weight: bold;
font-stretch: normal;
font-style: normal;
line-height: 1.86;
letter-spacing: normal;
}
/* marquee css */
.marquee {
height: auto;
margin: 20px 5%;
margin-bottom: 0;
display: grid;
grid-template-areas: "headline subhead"
"cta cta";
grid-template-rows: minmax(20rem, auto) minmax(10rem, auto);
column-gap: 3rem;
flex: 1 1;
-webkit-flex: 1 1;
}
.headline {
grid-area: headline;
align-self: center;
color: #fff;
font-family: Helvetica, sans-serif;
font-size: 5.25rem;
line-height: 5.25rem;
letter-spacing: -2.2px;
}
.subhead {
grid-area: subhead;
align-self: center;
color: #fff;
font-size: 0.875rem;
line-height: 1.625rem;
letter-spacing: normal;
font-weight: normal;
font-stretch: normal;
font-style: normal;
}
/*cta css*/
.cta {
background-color: #fff;
color: #000;
grid-area: cta;
display: flex;
flex-direction: row;
}
.cta > p {
position: relative;
align-self: center;
font-family: inherit;
font-size: 1.5rem;
font-weight: bold;
font-stretch: normal;
font-style: normal;
line-height: 2rem;
letter-spacing: -0.63px;
}
解决方案
实际上,我似乎通过将顶部和底部边距更改为 vh 并确保所有元素的总 vh 值等于 100vh 来解决问题。
推荐阅读
- swift - 添加多个 pod
- python - 创建谢尔宾斯基三角形
- visual-studio - Android模拟器错误:无法启动模拟器pixel_2_pie_9_0__-_api_28
- c++ - 我有一个#include 错误
提出“没有这样的文件或目录” - r - 使用 jsonlite 从 json 文件中读取 n 行时出现“错误:解析错误:过早的 EOF”错误
- swift - 如何让 WKWebView 像 SFSafariViewController 一样全屏显示?
- excel - 连接直到“文本”
- reactjs - 带有 React 和 Next.js 的 UIkit 图标
- azure - PowerBI for Azure Storage 中的查询筛选
- linux - 具有 sudo 权限的 bash 脚本