CSS 少@import 不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15459764/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 22:03:24  来源:igfitidea点击:

less @import not working

csswebless

提问by Kevin Lewis

<head>
    <link rel="stylesheet/less" href="less/news.less">
</head>
<body>
    <script src="less.js"></script>
</body>

news.less looks like this;

news.less 看起来像这样;

@import: "libs/base.less"

base.less looks like this;

base.less 看起来像这样;

@import "colors.less";
@import "mixins.less";
@import "bootstap.less";
@import "font-aweseome.less"

body {
    background-color: @light-grey;
}

bootstrap.less and font-awesome.less are CSS files with an altered extension. All the files are in the right folders.

bootstrap.less 和 font-awesome.less 是具有更改扩展名的 CSS 文件。所有文件都在正确的文件夹中。

When looking in the browser, styling in base.less is being ignored, meaning that my imports are not working.

在浏览器中查看时,base.less 中的样式被忽略,这意味着我的导入不起作用。

Can anyone give any tips?

任何人都可以提供任何提示吗?

Thanks!

谢谢!

回答by jonschlinkert

Your @importstatements must follow this format:

您的@import陈述必须遵循以下格式:

@import "styles.less";

@import "font-aweseome.less"isn't working because there is no semicolon at the end.

@import "font-aweseome.less"不起作用,因为最后没有分号。

@import: "libs/base.less"won't work because there is a colon after the import statement.

@import: "libs/base.less"将不起作用,因为 import 语句后有一个冒号。

回答by Tamás Pap

Why the colon in:

为什么冒号在:

@import: "libs/base.less"

I think is better to have a semicolon after all @import-s.

我认为毕竟@import-s 最好有一个分号。

Take a look in the console to make sure the paths are correct, and the browser isn't trying to load a less file from the wrong url.

查看控制台以确保路径正确,并且浏览器不会尝试从错误的 url 加载较少的文件。

回答by Abdul Basit

Try this:@import url('Your Path');

试试这个:@import url('你的路径');

回答by Fel

to import is

导入是

@import "styles.less";

回答by Dhayalan

1.Import your base.less in news.less like,

1.在news.less like中导入你的base.less,

    @import "libs/base.less";

2.Refer your news.less file in the html

2.在html中引用你的news.less文件

    <link  rel="stylesheet/less" type="text/css"  href="less/news.less"/>

3.Refer less.js library in the html

3.在html中引用less.js库

    <script src="lib/less.js"></script>