首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何显示3-4-3 flexbox表?

如何显示3-4-3 flexbox表?
EN

Stack Overflow用户
提问于 2021-01-27 13:56:18
回答 1查看 32关注 0票数 0

我正在尝试让我的内容像这样显示picture

但是我的picture是这样的

如何使一行有3列,第二行有4列,最后一行有3列?使用flexbox?谢谢

代码语言:javascript
复制
.flex-container {
    display: flex;
    flex-flow: row wrap;
    justify-content: center;
    background-color: white;
    align-items:baseline;
    width: 60em;
    margin: auto;
    padding: .5em;
    justify-content: space-between;
}

.flex-container div {

    flex: 1 0 30%;
    margin: .5em 0;
    text-align: center;
    line-height: 1.5em;
    font-size: 1em;
    border: 0.1em solid black;
    padding: 5px;
    box-sizing: border-box;
    justify-content: space-between;
    
}
EN

回答 1

Stack Overflow用户

发布于 2021-01-27 14:13:38

您可以通过将单元格放置到行中来实现这一点,这些行本身使用flex-direction: column进行堆叠。

样式很粗糙,但请尝试如下所示:

代码语言:javascript
复制
.outer {
    display: flex;
    flex-direction: column;
}

.row {
    display: flex;
    flex-direction: row;
}

.cell {
    margin: 1.0em;
    padding: 1.0em;
    border: 1px solid black;
    flex-grow: 1;
}
代码语言:javascript
复制
<div class="outer">
    <div class="row">
        <div class="cell">Cell 1</div>
        <div class="cell">Cell 2</div>
        <div class="cell">Cell 3</div>
    </div>
    <div class="row">
        <div class="cell">Cell 3</div>
        <div class="cell">Cell 4</div>
        <div class="cell">Cell 5</div>
        <div class="cell">Cell 6</div>
    </div>
    <div class="row">
        <div class="cell">Cell 7</div>
        <div class="cell">Cell 8</div>
        <div class="cell">Cell 9</div>
    </div>
</div>

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65913597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档