小编Hap*_*rei的帖子

用flexbox强制最后一个div换行

我有这个HTML

<div class="wrap">
     <div class="one"></div>
     <div class="two"></div>
     <div class="three"></div>
     <div class="four"></div>
</div> 
Run Code Online (Sandbox Code Playgroud)

加上这个CSS

.wrap {
    display: flex;
    align-items: center;
}

.one {
    flex: 0 1 200px;
}

.two {
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
}

.three {
    display: flex;
    flex: 0 1 200px;
    justify-content: flex-end;
}

.four {
    ???
}
Run Code Online (Sandbox Code Playgroud)

我想使它看起来像这样,我不知道还有什么用于.four来使最后一个div在新行上移动并加上100%的宽度

[- one -----][----- two -----][----- three -]
[----------------- four --------------------]
Run Code Online (Sandbox Code Playgroud)

atm看起来像这样

[- one -----][----- two -----][----- three -] [- four -----]
Run Code Online (Sandbox Code Playgroud)

我知道我可以再用

<div class="wrap"> …
Run Code Online (Sandbox Code Playgroud)

css css3 flexbox

3
推荐指数
1
解决办法
4052
查看次数

标签 统计

css ×1

css3 ×1

flexbox ×1