pinews
V2EX  ›  设计

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

  •  
  •   pinews · Sep 29, 2018 · 4082 views
    This topic created in 2785 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
        1
    des  
       Sep 29, 2018 via Android
    justify-content 设置主轴对齐
    align-items 设置侧轴对齐

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