【发布时间】:2016-12-06 01:11:34
【问题描述】:
我正在尝试在同一容器上创建一个具有全角和多列的 flexbox 行。
我尝试过flex-break: after;,但不确定我缺少什么。我试图避免有多个类,如 .fullwidth 和 .multiple-columns。
这就是我想要达到的目标:
------------------------
| |
| |
| item A |
| |
| |
------------------------
| | |
| | |
| B | C |
| | |
| | |
------------------------
| |
| |
| item D |
| |
| |
------------------------
.collage {
position: relative;
display: flex;
justify-content: flex-start;
align-items: center;
}
.fullwidth {
flex-break: after;
}
.collage-item {
width: 100%;
height: 25vw;
background: url("https://www.audi.co.uk/content/dam/audi/production/Models/NewModelsgallery/A5range/A5_Coupe/MY17/1920x1080_A5-Coupe-2016-side.jpg") no-repeat;
background-size: cover;
}
.btn {
position: absolute;
border: 2px solid white;
padding: 10px 18px;
text-align: center;
right: 8px;
bottom: 8px;
color: white;
text-decoration: none;
}
<div class="collage">
<!-- fullwidth -->
<div class="collage-item fullwidth"></div>
<!-- two columns -->
<div class="collage-item"></div>
<div class="collage-item"></div>
<!-- fullwidth -->
<div class="collage-item fullwidth"></div>
<div class="btn">Button</div>
</div>
【问题讨论】: