- 语言特点
- Less - 嵌套规则
- Less - 嵌套指令和冒泡
- 减 - 运营
- 少 - 逃避
- 更少 - 函数
- Less - 命名空间和访问器
- 减 - 范围
- 少 - 评论
- 减 - 导入
- 少 - 变量
- 减少 - 扩展
- 更少 - 混合
- Less - 参数混合
- Less - Mixin 作为函数
- Less - 将规则集传递给 Mixins
- 减 - 进口指令
- 更少 - 导入选项
- Less - Mixin 守卫
- 更少 - CSS 守卫
- 更少 - 循环
- 少 - 合并
- Less - 父选择器
- 功能
- Less - 杂项函数
- Less - 字符串函数
- Less - 列表函数
- Less - 数学函数
- Less 类型函数
- Less - 颜色定义函数
- Less - 颜色通道函数
- Less-颜色操作
- Less - 颜色混合函数
- 用法
- Less - 命令行使用
- 在浏览器中减少使用
- 更少 - 浏览器支持
- 更少 - 插件
- Less - 程序化使用
- Less - 在线编译器
- 更少 - GUI
- Less - 编辑器和插件
- Less - 第三方编译器
- 更少 - 框架
- 不太有用的资源
- 更少 - 快速指南
- 较少 - 有用的资源
- 少 - 讨论
LESS - 导入
描述
它用于导入 LESS 或 CSS 文件的内容。
例子
以下示例演示了在 LESS 文件中导入的用法 -
<html>
<head>
<title>Less Importing</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<h1>Example using Importing</h1>
<p class = "myclass">LESS enables customizable,
manageable and reusable style sheet for web site.</p>
<p class = "myclass1">It allows reusing CSS code and
writing LESS code with same semantics.</p>
<p class = "myclass2">LESS supports creating cleaner,
cross-browser friendly CSS faster and easier.</p>
</body>
</html>
现在创建myfile.less文件。
myfile.less
.myclass {
color: #FF8000;
}
.myclass1 {
color: #5882FA;
}
现在创建style.less文件。
无风格
@import "http://www.tutorialspoint.com/less/myfile.less";
.myclass2 {
color: #FF0000;
}
myfile.less文件将从路径https://www.tutorialspoint.com/less/myfile.less导入到style.less中
您可以使用以下命令将style.less文件编译为style.css -
lessc style.less style.css
执行上述命令;它将使用以下代码自动创建style.css文件 -
样式.css
.myclass {
color: #FF8000;
}
.myclass1 {
color: #5882FA;
}
.myclass2 {
color: #FF0000;
}
输出
按照以下步骤查看上面的代码是如何工作的 -
将以上 html 代码保存在importing.html文件中。
在浏览器中打开此 HTML 文件,将显示以下输出。
