Do I not understand the flex-grow property?

后端 未结 3 635
孤街浪徒
孤街浪徒 2020-12-02 17:53

I\'m afraid I must not understand flex-grow. If you jump to the JSFiddle below - the way I understand it, .big should be three times the size of the other

3条回答
  •  半阙折子戏
    2020-12-02 18:42

    You have to specify a value for flex-basis as well (not specifying this property causes behaviour similar to using the initial value, auto).

    Add flex-basis: 0; to both children or just set it with the shorthand:

    .flex-item {
        flex: 1; /* flex-basis is 0 if omitted */
    }
    .big {
        flex-grow: 3;
    }
    

    http://codepen.io/anon/pen/JEcBa

提交回复
热议问题