规则@container scss 未知(unknownAtRules)

发布于 2025-01-11 12:22:14 字数 1265 浏览 0 评论 0原文

我希望这对你们来说是一个简单的问题:(。我通过安装“container-query-polyfill”使用容器查询时遇到问题。当然,我从 Chrome 中启用了 css 容器查询标志。在我的容器(父)类中,我添加 contains: inline-size; 并为了响应性,我为子类添加 @container ,如下所示,

 div.model-holdings-advanced-module {
 container: inline-size;
 @container size(max-width: sizing.$standard-tablet) {
 .table-component-wrapper {
  overflow-x: scroll;
  table.table-component {
    tr > :first-child {
      position: -webkit-sticky;
      position: sticky;
      left: 0;
      z-index: 999;
  }
 }
}
}

但它抱怨容器和 @container 是“未知的规则 @container scss(unknownAtRules)”。很多教程,100%都使用css,所以我认为问题可能来自于将scss转换为css。因为我使用的是Webpack,所以我做了这样的事情

  mode: 'production',
  module: {
  rules: [
    {
      test: /\.m?jsx?$/,
      exclude: /(node_modules)/,
      loader: 'babel-loader',
      query: {
        presets: ['@babel/preset-env'], //Preset used for env setup
      },
    },
            {
      test: /\.s[ac]ss$/,
      use: [
        'raw-loader',
        {
          loader: 'sass-loader',
          options: {
            sassOptions: {
              includePaths: [path.resolve(__dirname, 'node_modules')],
            },
          },
        },
      ],
    },,
  ],
},

,但现在我不确定是否有帮助。问题来自于在 scss 中使用容器查询、语法错误或其他原因。

I hope it would be a simple question for you guys :(. I have a problem using container query by installing "container-query-polyfill". Of course, I enabled css container query flag from Chrome. In my container(parent) class, I add contain: inline-size; and for responsiveness, I add @container for child class as following.

 div.model-holdings-advanced-module {
 container: inline-size;
 @container size(max-width: sizing.$standard-tablet) {
 .table-component-wrapper {
  overflow-x: scroll;
  table.table-component {
    tr > :first-child {
      position: -webkit-sticky;
      position: sticky;
      left: 0;
      z-index: 999;
  }
 }
}
}

But it complains that container and @container is "Unknown at rule @container scss(unknownAtRules)". I check many tutorials, 100% of them use css, so I assumed that the problem might come from transforming scss to css. Since I am using Webpack, I did something like this

  mode: 'production',
  module: {
  rules: [
    {
      test: /\.m?jsx?$/,
      exclude: /(node_modules)/,
      loader: 'babel-loader',
      query: {
        presets: ['@babel/preset-env'], //Preset used for env setup
      },
    },
            {
      test: /\.s[ac]ss$/,
      use: [
        'raw-loader',
        {
          loader: 'sass-loader',
          options: {
            sassOptions: {
              includePaths: [path.resolve(__dirname, 'node_modules')],
            },
          },
        },
      ],
    },,
  ],
},

it didn't help at all. Now I am not sure if there is a problem coming from either using container query in scss, syntax error, or something else.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一萌ing 2025-01-18 12:22:15

我认为这是由于 sass linter 尚未使用 @container 规则的最新定义进行更新。这不是语法错误,只是所有浏览器尚未完全支持容器查询。

我认为你可以添加“scss.lint.unknownAtRules”:“忽略”。忽略此类消息

希望有帮助

I think this is due the sass linter not yet updated with latest definitions for @container rules. This is not a syntax error, is just container queries aren't yet fully supported on all browsers.

You can add I think "scss.lint.unknownAtRules": "ignore". to ignore this kind of messages

Hope it helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文