- 语言特性
- Less - 嵌套规则
- Less - 嵌套指令和冒泡
- Less - 操作符
- Less - 转义
- Less - 函数
- Less - 命名空间和访问器
- Less - 范围
- Less - 注释
- Less - 导入
- Less - 变量
- Less - 扩展
- Less - 混合宏
- Less - 参数化混合宏
- Less - 混合宏作为函数
- Less - 向混合宏传递规则集
- Less - 导入指令
- Less - 导入选项
- Less - 混合宏守卫
- Less - CSS 守卫
- Less - 循环
- Less - 合并
- Less - 父选择器
- 函数
- Less - 杂项函数
- Less - 字符串函数
- Less - 列表函数
- Less - 数学函数
- Less - 类型函数
- Less - 颜色定义函数
- Less - 颜色通道函数
- Less - 颜色操作
- Less - 颜色混合函数
- 用法
- Less - 命令行用法
- 在浏览器中使用 Less
- Less - 浏览器支持
- Less - 插件
- Less - 程序化用法
- Less - 在线编译器
- Less - 图形界面
- Less - 编辑器和插件
- Less - 第三方编译器
- Less - 框架
- Less 有用资源
- Less - 快速指南
- Less - 有用资源
- Less - 讨论
LESS - 导入选项 Less 关键字
描述
@import (less) 将文件作为 LESS 文件导入,无论文件扩展名是什么。此功能在1.4.0 版本中发布。
示例
以下示例演示了在 LESS 文件中使用less关键字:
<html>
<head>
<link rel = "stylesheet" href = "style.css" type = "text/css" />
<title>Import Options Less</title>
</head>
<body>
<h1>Welcome to Tutorialspoint</h1>
<p class = "para_1">LESS is a CSS pre-processor that
enables customizable, manageable and reusable style sheet for web site.</p>
<p class = "para_2">LESS is a CSS pre-processor that
enables customizable, manageable and reusable style sheet for web site.</p>
</body>
</html>
接下来,创建style.less文件。
style.less
@import (less) "https://tutorialspoint.com/less/less.txt";
.para_1 {
color: red;
.style;
}
.para_2 {
color: blue;
}
以下代码将从https://tutorialspoint.com/less/less.txt路径将 less.txt 文件导入到 style.less 中:
less.txt
.style {
font-family: "Comic Sans MS";
font-size: 20px;
}
您可以使用以下命令将style.less编译为style.css:
lessc style.less style.css
执行上述命令;它将自动创建style.css文件,其中包含以下代码:
style.css
.style {
font-family: "Comic Sans MS";
font-size: 20px;
}
.para_1 {
color: red;
font-family: "Comic Sans MS";
font-size: 20px;
}
.para_2 {
color: blue;
}
输出
请按照以下步骤查看上述代码的工作原理:
将上述 html 代码保存在import_options_less.html文件中。
在浏览器中打开此 HTML 文件,将显示以下输出。
less_import_options.htm
广告