less

less :是一门css预处理语言

它需要一种编译语言去把它转换成css
1.使用@定义变量。

@width:100px;
div {
  width: @width;
  height: @width;
  background: blue;
}
p{
    width: @width;
    height: @width;
    background: red;
}

使用编译器后转换为css

div {
  width: 100px;
  height: 100px;
  background: blue;
}
p {
  width: 100px;
  height: 100px;
  background: red;
}

2.混合模式带参(可不带参)

.two(@w:100px,@h:100px,@b:red){
    width:@w; height: @h; background:@b;
}
div{
    .two()

}
p{
    .two()
}

使用编译器后转换为css

div {
  width: 100px;
  height: 100px;
  background: #ff0000;
}
p {
  width: 100px;
  height: 100px;
  background: #ff0000;
}

3.嵌套

.w_h(@w: 600px, @h: 800px, @b: #fff) {
    width: @w;
    height: @h;
    background: @b
}

.one {
    .w_h();
    margin: auto;

    ul {
        .w_h();

        li {
            .w_h(600px, 50px, pink);
            list-style-type: none;
            height: 50px;
            text-align: center;
            a{
                text-decoration: none;
                &:hover{color:blueviolet;}
            }
        }
    }
}

使用编译器后转换为css

.one {
  width: 600px;
  height: 800px;
  background: #ffffff;
  margin: auto;
}
.one ul {
  width: 600px;
  height: 800px;
  background: #ffffff;
}
.one ul li {
  width: 600px;
  background: #ffc0cb;
  list-style-type: none;
  height: 50px;
  text-align: center;
}
.one ul li a {
  text-decoration: none;
}
.one ul li a:hover {
  color: blueviolet;
}

4 @arguments 选取所有参数

.border(@w: 1px, @s: solid, @b: #333) {
    border: @arguments
}

使用编译器后转换为css

 border: 1px solid #333333;

5.@import 导入其他模块(.css, .html, .js ,.php…)

@import '2.less';

注意:less后缀可以省略

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值