我是靠谱客的博主 孝顺金毛,这篇文章主要介绍Less 安装及基本用法,现在分享给大家,希望可以做个参考。

node.js是一个前端的框架 自带一个包管理工具npm

node.js 的安装

官网:http://nodejs.cn/

在命令行检验是否安装成功

切换到项目目录,初始化了一个package.json文件

安装与卸载jQuery包(例子)  安装

  卸载

安装淘宝镜像

2. 安装less

试一试:

test.html

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="style.css" rel="external nofollow" /> </head> <body> <div id="box"> <ul> <li>你好</li> <li>hello</li> </ul> </div> </body> </html>

style.less

复制代码
1
2
3
4
5
6
7
8
9
10
11
#box{ width:200px; height:200px; background-color:blue; ul{ color:white; li{ line-height:50px; } } }

在命令行中输入lessc xxx.less xxx.css,

如下:

用浏览器打开test.html 看一下效果吧3. less 的基本用法

https://less.bootcss.com/

变量

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
@red:red; @w:200px; #big{ width:@w; height:@w; background-color:@red; #small{ width:@w; height:@w; background-color:@red; } } p{ color:@red; }

混合

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
.bt{ width:200px; height:200px; border-top:2px solid red; background-color:red; } #big{ .bt; #small{ .bt; } }

•嵌套

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#box{ width:100%; height:60px; background-color:#ccc; h3{ width:100%; height:20px; background-color:yellow; } ul{ list-style:none; li{ height:40px; line-height:40px; float:left; padding:0 10px; } } }

•运算

复制代码
1
2
3
4
5
6
7
8
9
10
11
@color:#333; #box{ width:100%; height:60px; background-color:@color+#111; } •calc() @var:50vh/2; #box{ width:calc(50% + (@var - 20px)); }

•固定函数

复制代码
1
2
3
4
5
6
7
@base:#f04615; @width:0.5; #box{ width:percentage(@width); color:saturate(@base,5%); background-color:spin(lighten(@base,25%),8); }

•注释

复制代码
1
2
3
4
5
//单行注释// /*多行 注释*/ •引入其他less文件 @import "other.less";

总结

以上所述是小编给大家介绍的Less安装及基本用法,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!

最后

以上就是孝顺金毛最近收集整理的关于Less 安装及基本用法的全部内容,更多相关Less内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(164)

评论列表共有 0 条评论

立即
投稿
返回
顶部