简体   繁体   English

SCSS:-ms-prefix 导致 CSS 文件中的错误

[英]SCSS: -ms-prefix causes error in CSS file

I am using the Live Sass Compiler in Visual Studio Code.我在 Visual Studio Code 中使用Live Sass 编译器

My SCSS file contains this grid:我的 SCSS 文件包含这个网格:

$grid-cols: 12;
$grid-gutter-x: 16px;
$grid-gutter-y: 16px;

.grid {
    position: relative;
    width: 100%;
    display: grid;
    grid-template-columns: repeat($grid-cols, minmax(0, 1fr)) !important; 
    grid-gap: $grid-gutter-x $grid-gutter-y;
}

The compiled CSS code:编译后的CSS代码:

.grid {
  position: relative;
  width: 100%;
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (minmax(0, 1fr))[12] !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  grid-gap: 16px 16px;
}

As a result, I get four errors:结果,我得到四个错误:

] expected
semi-colon expected
{ expected
{ expected

This line causes the errors:此行导致错误:

 -ms-grid-columns: (minmax(0, 1fr))[12] !important;

My Question is: Is it possible to ignore the following line?我的问题是:是否可以忽略以下行? Can I prevent my compiler to add the -ms prefix?我可以阻止我的编译器添加-ms前缀吗? Or is there another way to solve this problem?或者还有其他方法可以解决这个问题吗?

 grid-template-columns: repeat($grid-cols, minmax(0, 1fr)) !important; 

You can check the Live Sass Complier documentation您可以查看 Live Sass 编译器文档

And you will see this:你会看到这个:

liveSassCompile.settings.autoprefix : Automatically add vendor prefixes to unsupported CSS properties (eg transform -> -ms-transform ). liveSassCompile.settings.autoprefix :自动将供应商前缀添加到不受支持的 CSS 属性(例如transform -> -ms-transform )。

Specify what browsers to target with an array of strings (uses Browserslist ).使用字符串数组指定要定位的浏览器(使用Browserslist )。

Set null to turn off.将 null 设置为关闭。 (Default is null ) (默认为null

Example:例子:

 "liveSassCompile.settings.autoprefix": [ "> 1%", "last 2 versions" ]

So if this is null by default check if you already set this in your settings, if so change accordingly to fix your issue因此,如果默认情况下这是null ,请检查您是否已经在设置中进行了设置,如果是,请相应更改以解决您的问题

Use the latest version(4.3.0) of Live Sass Compiler extension on vscode, it fixed the same issue for me.在 vscode 上使用 Live Sass 编译器扩展的最新版本(4.3.0),它为我解决了同样的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM