pinews
V2EX  ›  设计

flex 项目的 flex 属性为什么只对横轴有效呢,为什么没有相应的纵轴属性呢?

  •  
  •   pinews · Sep 29, 2018 · 4626 views
    This topic created in 2972 days ago, the information mentioned may be changed or developed.
    真诚请教,justify-content 可以让 flex 项目有相应的对齐方式,但我想模拟对齐效果,在原来的 flex 项目前后加入空白的项目,然后用 flex 属性控制,但是在纵轴上却无能为力,因为 flex 属性只对横轴有效,请问有没有较好的解决办法,因为用 flex 套 flex 的用法在一些情况下不太合适。谢谢。
    Supplement 1  ·  Oct 1, 2018
    我所说的是为了重新设计游戏淘汰赛赛程的效果
    如下
    http://www.dota2.com/international/standings/
    7 replies  •  2018-10-01 16:47:15 +08:00
    des
    des
    Sep 29, 2018 via Android
    1
    justify-content 设置主轴对齐
    align-items 设置侧轴对齐

    如果你想要嵌套 flex 的那种效果,请使用 grid 布局
    binaryify
    binaryify
    Sep 29, 2018
    2
    flex-direction: column
    Jackliu
    Jackliu
    Sep 29, 2018
    3
    flex-direction
    Edwards
    Edwards
    Sep 29, 2018
    4
    你需要先确定主轴和交叉轴这个东西,
    取决于 flex-direction。justify-content 指的是主轴方向的排布,align-item 指的是交叉轴上的排布
    pinews
    pinews
    OP
    Sep 29, 2018
    6
    @binaryify
    @Jackliu
    @Edwards 横轴我已经用了,用了 flex-direction: column,原来的横轴就不能用了,结果是一样的。
    pinews
    pinews
    OP
    Oct 1, 2018
    7
    @des 对齐我只是举例,我想说的是 flex,flex 方向默认是从左至右的,也可以先从上至下然后从左至右,请问 grid 怎么实现这个效果?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3877 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 01:06 · PVG 09:06 · LAX 17:06 · JFK 20:06
    ♥ Do have faith in what you're doing.