【问题标题】:CSS flexbox SASS mixin that supports no flexbox legacyCSS flexbox SASS mixin,不支持 flexbox legacy
【发布时间】:2019-10-27 16:37:31
【问题描述】:

有没有办法在使用 SASS mixins 时支持没有 flexbox legacy(IE) 的浏览器?

我正在使用下面的 mixin 来快速实现 display:flex。虽然我对 IE 有一些问题,但因为我必须针对使用 mixin 的每个类来使用 modernizr 将其切换到 display:tabledisplay:table-cell,因为某些浏览器不完全支持 display:flex .

@mixin flexbox() {
    display: -webkit-box !important;
    display: -moz-box !important;
    display: -ms-flexbox !important;
    display: -webkit-flex !important;
    display: flex !important;
}

如果我的 mixin 在 body 内,并且类为 flexboxlegacyno-flexboxlegacy,我是否可以对它进行调节?

【问题讨论】:

    标签: css internet-explorer sass flexbox


    【解决方案1】:
    @mixin flexbox() {
      display: flex;
    
      .no-flexboxlegacy & {
        display: table;
      }
    }
    
    a b c {
      @include flexbox();
    }
    

    编译为:

    a b c {
      display: flex;
    }
    
    .no-flexboxlegacy a b c {
      display: table;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-07-01
      • 2021-02-15
      • 1970-01-01
      • 2015-05-29
      • 2021-08-09
      • 1970-01-01
      • 2015-09-15
      • 2021-02-23
      相关资源
      最近更新 更多