【问题标题】:Align-items: center overriding justify-content: space-around对齐项目:居中覆盖 justify-content:空格
【发布时间】:2023-04-06 11:28:01
【问题描述】:

我想要一个居中的弹性列布局,其中一些项目在一行中,它们之间有空格。

html:

    <div class="flex">
        <h1>Welcome</h1>
        <p>
            Before you start there's a short introduction
        </p>
        <p>
            <b>Do you want to see it?</b>
        </p>
        <div class="flex-row">
            <span><b>Skip</b></span>
            <button>Start</button>
        </div>
    </div>

css:

.flex {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.flex-row {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

问题是当父容器有 align-items: center 时,flex-row space-between 不起作用,我不知道如何忽略 flex-row。

【问题讨论】:

  • 你需要设置 flex-row 宽度

标签: css flexbox


【解决方案1】:

尝试切换

align-items: center;

text-align: center;

但是自从

justify-content: space-between;

为您提供两个项目之间的最大空间尝试调整网站的宽度。

【讨论】:

    猜你喜欢
    • 2017-01-28
    • 2021-10-19
    • 2013-12-06
    • 1970-01-01
    • 2014-06-30
    • 2021-10-25
    • 2015-03-22
    • 2015-03-28
    • 2017-02-02
    相关资源
    最近更新 更多