【问题标题】:Flex Wrap and Evenly Distribute Between RowsFlex Wrap 并在行之间均匀分布
【发布时间】:2018-06-01 16:36:44
【问题描述】:

你好。上面显示的图像是一个按钮菜单(文本已被故意混淆)。菜单在功能上按预期将项目移动到第二行,但它不会在行之间均匀地间隔项目。我已经在网上查找了解决方案,但它们要么不起作用(对我来说,有些甚至在它自己的小提琴中),要么它们的限制太大。谁能推荐一种让项目在两(或更多)行之间平均分配的方法?

这是相关的 CSS:

#tabs {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    background-color: rgb(50,50,50);
    justify-content: space-around;
}

#tabs button {
    background-color: <?php echo $style['buttonColor']; ?>;
    color: white;
    margin-left: 5px;
    margin-right: 5px;
    margin-top: 10px;
    margin-bottom: 10px;
    padding: 10px;
    font-size: 18px;
    border: 1px solid black;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;
}

【问题讨论】:

    标签: css flexbox


    【解决方案1】:

    您可以将flex-grow: 1 添加到您的子元素中,以使它们填充空白空间。

    https://jsfiddle.net/sabvyfow/

    如果您想要动态中断的每列中的偶数,您可能不得不在某些中断点诉诸媒体查询:https://www.w3schools.com/css/css3_mediaqueries.asp

    【讨论】:

    • 感谢您的提示。我将继续研究选项,但最坏的情况是,我将使用媒体查询来帮助解决问题。
    猜你喜欢
    • 2018-03-22
    • 1970-01-01
    • 2020-07-15
    • 2011-04-04
    • 1970-01-01
    • 2023-01-11
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多