【发布时间】:2021-09-03 12:01:13
【问题描述】:
我有一个小问题。我正在尝试使用 HTML 和 CSS 编写这样的布局:
Here's the picture of what i want
我看了这个问题: Flexbox 3 divs, two columns, one with two rows 。唯一的问题是你不能给 div 一个边距而不破坏布局。
如果左图较高,则右图应使用剩余空间。 (只有几个盒子我尝试先正确放置。我想私下做造型,所以不要怀疑。)
这是我到目前为止尝试过的代码(按整页。在这个小窗口中,您只能看到移动版本):
* {
margin: 0;
padding: 0;
}
#showroom {
height: 500px;
width: 100%;
background: red; /* To see showroom Background */
padding: 1em;
display: flex;
}
#boxOne {
height: 100%;
width: 50%;
background: grey;
margin: 10px;
float: left;
}
#showroom #boxTwo {
width: 50%;
height: 50%;
background: grey;
margin: 10px;
}
#showroom #boxThree {
width: 50%;
height: 50%;
background: grey;
margin: 10px;
}
@media only screen and (max-width: 750px) {
#showroom {
display: flex;
align-items: center;
flex-direction: column;
}
#showroom #boxOne, #showroom #boxTwo, #showroom #boxThree {
height: 33.3%;
width: 100%;
}
}
<div id="showroom">
<div id="boxOne"></div>
<div id="boxTwo"></div>
<div id="boxThree"></div>
</div>
【问题讨论】:
-
这是 HTML 的结尾还是你可以改变一下?
-
@AristeidisKaravas 你会添加什么?