gpt4 book ai didi

css - 使用带有 % 填充元素的宽高比时,Flexbox 在 Firefox 中不起作用

转载 作者:行者123 更新时间:2023-12-04 21:39:58 26 4
gpt4 key购买 nike

<分区>

我已使用 flexbox 根据此插图成功创建了所需的元素布局:

elements layout achieved with flexbox

但是,它似乎在 Firefox 中不起作用。 Firefox 不尊重被设置为保持纵横比的内部元素。我试过 here 的答案, 但它没有帮助。

*请忽略 flex 指令缺少前缀的问题。我在我的代码中使用了 autoprefixer,因此输出 CSS 将包含它们。

.box {
width: 100%;
padding-bottom: 66.199%;
background: #eee;
position: relative;
overflow: hidden;
}
.flex-grid {
display: flex;
display: -webkit-flex;
flex-direction: column;
min-height: 100%;
}
.flex-grid .flex-grid-container {
display: flex !important;
display: -webkit-flex;
flex: 1 !important;
}
.flex-grid .flex-grid-container > .flex-grid-child {
margin-right: 20px;
margin-bottom: 20px;
}
.flex-grid .flex-grid-container > .flex-grid-child:last-of-type {
margin-right: 0px;
}
.flex-grid .flex-grid-row, .flex-grid .flex-grid-column {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: flex-start;
margin-bottom: 0px;
}
.flex-grid .flex-grid-column {
flex-direction: column;
}
.flex-grid .flex-grid-column .flex-grid-child {
margin-right: 10px;
margin-bottom: 20px;
overflow: hidden;
}
.flex-grid .flex-grid-column .flex-grid-child:last-of-type {
margin-bottom: 0px;
}
.flex-grid .flex-grid-column:last-of-type .flex-grid-child {
margin-right: 0px;
margin-left: 10px;
}
.flex-grid .flex-grid-mother {
flex: 1;
align-self: auto;
}
.flex-grid .flex-grid-child {
flex: 1;
align-self: auto;
display: flex;
display: -webkit-flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
}
<div class="flex-grid">
<div class="flex-grid-container flex-grid-mother flex-grid-row">
<div class="flex-grid-child">
<div class="box"></div>
</div>
<div class="flex-grid-child flex-grid-row">
<div class="flex-grid-child flex-grid-column">
<div class="flex-grid-child">
<div class="box"></div>
</div>
<div class="flex-grid-child">
<div class="box"></div>
</div>
</div>
<div class="flex-grid-child flex-grid-column">
<div class="flex-grid-child">
<div class="box"></div>
</div>
<div class="flex-grid-child">
<div class="box"></div>
</div>
</div>
</div>
</div>
</div>

Here is the CodePen

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com