SCSS 编译后将 @import 保留在 CSS 的末尾

编程入门 行业动态 更新时间:2024-10-27 21:15:29
本文介绍了SCSS 编译后将 @import 保留在 CSS 的末尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们需要将 @import 放在我的 CSS 文件的末尾.例如:

We need to put @import at the end of my CSS file. For example:

SCSS:

@import "reset.css"; Body { font: 0.8em arial; } @import "customation.css"

编译为:

@import "reset.css";body{font: 0.8em arial;}@import "customation.css"

但编译后它改变了@import顺序,CSS文件将是这样的:

but after compile it changed the @import order and CSS file will be this:

@import "reset.css";@import "customation.css";body{font: 0.8em arial;}

将@importing 文件放在custom.css 文件末尾对我们进行自定义非常重要.我们不能手动将 @import 放到 CSS 文件中,因为 SCSS 文件将被更改并且 CSS 文件将被重写.有什么建议吗?

It's very important for us to keep @importing the custom.css file at the end for our customization. We can't put the @import to CSS file manually because SCSS file will be changed and CSS file will be rewritten. Any suggestion?

推荐答案

您是否出于任何特定原因使用 @import?有性能影响,并且不再有主要用例.

Are you using @import for any particular reason? There are performance impacts, and no major use case anymore.

如果你使用 Sass 的 @import 来连接文件会更好,这也允许你按照你想要的顺序导入并依赖级联.

It would be better if you used Sass's @import to concatenate the file instead, this would also allow you to import in the order you want and rely on the cascade.

@import "reset"; Body { font: 0.8em arial; } @import "customation";

更多推荐

SCSS 编译后将 @import 保留在 CSS 的末尾

本文发布于:2023-11-13 14:08:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584522.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:末尾   后将   SCSS   CSS   import

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!