less

1.变量(用于定义常用参数)
@color:#fff;
body{
  color:@color;
}
变量计算    可以加减乘除
@color:#234152;
@deep-color:@color + #111;        //叠加后为#345163
@width:10px;
#header{
  width:@width * 3;
}
变量覆盖
@color:#222;
@color:#333;
最终输出#333,后面定义的变量讲覆盖前面定义的变量。
@arguments        //包含所有传递进来的参数
.box-shadow(@x:1px,@y:1px,@blur:2px;@color:@333){
   box-shadow:@arguments;
}


2.混合,一个类可以嵌套到另一个类中。被嵌套类继承嵌套类的样式。
.cricle(@radius:5px){
  border-radius:@radius;
  width:10px;
  height:10px;
}
#header{
  .cricle;        //header继承cricle样式
}
混入传参
.cricle(@radius){
  border-radius:@radius;
  width:10px;
  height:10px;
}
#header{
 .cricle(5px);
}
不带参数
.cricle(){
 broder-radius:10px;
}
#header{
  .cricle;
}

3.嵌套规则 子级元素可写在父级元素内部
div{
  color:red;
  p{        //p为div的子元素
    font-size:20px;
    }
  a{
    color:yellow;
    &:hover{ font-size:20px;}    //&指代当前对象
}

4.命名空间
#bundle{        //bundle命名空间下有两个类样式
  .button(){
    width:20px;
    height:20px;
  }
  .active{
     color:red;
  }
}

#header{
  font-size:#333;
  #bundle > .button;        //使用bundle命名空间下的.button样式
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值