flex-grow not sizing flex items as expected

前端 未结 5 1079
你的背包
你的背包 2020-11-22 11:55

It seems that the content inside a flex div affects its calculated size concerning the flex-grow property. Am I doing something wrong?

In the fiddle pr

5条回答
  •  迷失自我
    2020-11-22 12:21

    It is important to use the shorthand to accommodate cross browser support:

    .row {
        display: flex;
        flex-direction: row; /* <-- this is the default so unnecessary to state */
        flex-grow: 1;
        justify-content: space-between;
    }
    
    .button {
        display: flex;
       /* flex-grow: 1; replace with shorthand */ 
       flex:1 0 100%; /* probably making the "width: 100%;" unnecessary */
        justify-content: center;
    }
    
    .button#number0 {
        /* flex-grow: 2; replace with shorthand */ 
       flex:2 0 100%;
    }
    
    .button#colon {
        /* flex-grow: 1; replace with shorthand */ 
        flex:1 0 100%;
    }
    

提交回复
热议问题