我试图让我的flexbox符合它的容器,但我似乎错过了一个步骤,但不能找出什么。
附加片段。这是在媒体查询,但我添加了整个代码,以防万一它的帮助。你会注意到我的.f
在右边。它应该共享.b
和.c .d .e
两行
body {
background: papayawhip;
text-align: center;
font-size: 2em;
margin-bottom: 25px;
}
.container{
display: flex;
flex-direction: row;
flex-wrap: wrap;
height: 100vh;
justify-content: center;
row-gap:10px;
column-gap: 10px;
}
.a{
background-color: teal;
width: 80vw;
height: 20vh;
}
.b{
background-color: aliceblue;
width: 80vw;
height: 40vh;
margin-bottom: 10px;
}
.c{
background-color: #264b75;
width: 25vw;
height: 20vh;
}
.d{
background-color: #773535;
width: 25vw;
height: 20vh;
}
.e{
background-color: #e3b036;
width: 25vw;
height: 20vh;
}
.f{
background-color: #74446f;
width: 80vw;
height: 20vh;
}
.nonsense{
display: flex;
flex-flow: row;
justify-content: space-evenly;
}
/* desktop version */
@media (min-width: 300px){
.container{
display: flex;
flex-wrap: wrap;
flex-direction: column;
}
.broad{
display: flex;
flex-direction: column;
min-height: 60vh;
}
.b{
flex-direction: row;
width: 60vw;
align-self: flex-start;
}
.f{
width: 20vw;
height: 60vh;
align-self: flex-end;
}
.nonsense{
display: flex;
flex-direction: row;
width: 60vw;
column-gap: 10px;
}
}
<body>
<div class="container">
<div class="a">a</div>
<div class="broad">
<div class="b">b</div>
<div class="nonsense">
<div class="c">c</div>
<div class="d">d</div>
<div class="e">e</div>
</div>
</div>
<div class="f">f</div>
</div>
</body>
1条答案
按热度按时间jvidinwx1#
看起来每个元素都在vw中给定了宽度和高度值。当您为元素的容器指定一个常规值时,可以通过以百分比为单位指定宽度来调整子元素。