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

查看:825
本文介绍了将.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 文件将其视为较少。如果指定的文件较少,并且不包括扩展名,则将添加任何扩展名。

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天全站免登陆