将 .css 文件导入 .less 文件 [英] import .css file into .less file

查看:45
本文介绍了将 .css 文件导入 .less 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能将 .css 文件导入到 .less 文件中吗...?

Can you import .css files into .less files...?

我非常熟悉 less 并将其用于我的所有开发.我经常使用如下结构:

I'm pretty familiar with less and use it for all my development. I regularly use a structure as follows:

@import "normalize";

//styles here

@import "mixins";
@import "media-queries";
@import "print";

所有导入都是其他 .less 文件,并且一切正常.

All imports are other .less files and all works as it should.

我目前的问题是:我想将一个 .css 文件导入到 .less 中,该文件引用了 .css 文件中使用的样式,如下所示:

My current issue is this: I want to import a .css file into .less that references styles used in the .css file as follows:

@import "../style.css";

.small {
    font-size:60%;
    .type;
}
// other styles here

.css 文件包含一个名为 .type 的类,但是当我尝试编译 .less 文件时出现错误 NameError: .type is undefined

The .css file contains a class called .type but when I try to compile the .less file I get the error NameError: .type is undefined

.less 文件不会导入 .css 文件,只会导入其他 .less 文件吗...?还是我引用错了……?!

Will the .less file not import .css files, only other .less ones...? Or am I referencing it wrong...?!

推荐答案

您可以通过指定选项来强制将文件解释为特定类型,例如:

You can force a file to be interpreted as a particular type by specifying an option, e.g.:

@import (css) "lib";

会输出

@import "lib";

@import (less) "lib.css";

将导入 lib.css 文件并将其视为less.如果您指定的文件是 less 且不包含扩展名,则不会添加任何扩展名.

will import the lib.css file and treat it as less. If you specify a file is less and do not include an extension, none will be added.

这篇关于将 .css 文件导入 .less 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆