IE flexible box model not working

前端 未结 1 1345
小蘑菇
小蘑菇 2020-12-20 08:46

Im trying to implement the flexible box model into my website, and while its working for the -webkit-browsers like chrome and safari, other browsers like mozilla and opera,

相关标签:
1条回答
  • 2020-12-20 09:18

    IE doesn't use the deprecated 2009 Flexbox properties, it uses the ones from the deprecated March 2012 draft. Opera supports the Flexbox standard properties without prefixes and the 2009 properties under the -webkit- prefix.

    .holder {
      width: 100%;
      margin: auto;
      display: -webkit-box;
      display: -moz-box;
      display: -ms-flexbox;
      display: -webkit-flex;
      display: flex;
      -webkit-box-orient: vertical;
      -moz-box-orient: vertical;
      -webkit-box-direction: normal;
      -moz-box-direction: normal;
      -webkit-flex-direction: column;
      -ms-flex-direction: column;
      flex-direction: column;
      -webkit-box-flex: 1;
      -moz-box-flex: 1;
      -webkit-flex: 1;
      -ms-flex: 1;
      flex: 1;
      -webkit-box-pack: center;
      -moz-box-pack: center;
      -ms-flex-pack: center;
      -webkit-justify-content: center;
      justify-content: center;
      text-align: center;
    }
    
    .holder #new_div {
      width: 940px;
    }
    
    .holder div {
      /* justify-content does nothing here since this element isn't a flex container */
      -webkit-box-pack: center;
      -moz-box-pack: center;
      -ms-flex-pack: center;
      -webkit-justify-content: center;
      justify-content: center;
    }
    
    #new_div {
      margin: auto;
      display: -webkit-box;
      display: -moz-box;
      display: -ms-flexbox;
      display: -webkit-flex;
      display: flex;
      text-align: left;
      -webkit-box-flex: 1;
      -moz-box-flex: 1;
      -webkit-flex: 1;
      -ms-flex: 1;
      flex: 1;
      -webkit-box-pack: center;
      -moz-box-pack: center;
      -ms-flex-pack: center;
      -webkit-justify-content: center;
      justify-content: center;
      /* this shouldn't be necessary, as the default direction is `row` */
      -webkit-box-orient: horizontal;
      -moz-box-orient: horizontal;
      -webkit-box-direction: normal;
      -moz-box-direction: normal;
      -webkit-flex-direction: row;
      -ms-flex-direction: row;
      flex-direction: row;
      min-width: 940px;
      padding: 20px;
    }
    

    Also worth noting, this requires IE10+

    0 讨论(0)
提交回复
热议问题