Less学习

1.变量(Variables)

@width: 10px;
@height: @width + 10px;

#header {
  width: @width;
  height: @height;
}

2.混合:将一组属性从一个规则集包含到另一个规则集的方法。

.bordered {
  border-top: dotted 1px black;
  border-bottom: solid 2px black;
}
#menu a {
  color: #111;
  .bordered();
}

3.嵌套

#header {
  color: black;
  .navigation {
    font-size: 12px;
  }
  .logo {
    width: 300px;
  }
}

4.运算:算数运算符可以对任何数字、颜色或变量进行运算。

@incompatible-units: 2 + 5px - 3cm;
@var: 50vh/2;
width: calc(50% + (@var - 20px)); 

5.转义:允许使用任何字符串作为属性或变量值

@min768: ~"(min-width: 768px)";
.element {
  @media @min768 {
    font-size: 1.2rem;
  }
}

6.函数:转换颜色、处理字符串、算术运算等。

        1.if:

@some: foo;

div {
    margin: if((2 > 1), 0, 3px);
    color:  if((iscolor(@some)), @some, black);
}

//结果:
div {
    margin: 0;
    color:  black;
}

        2.boolean:

@bg: black;
@bg-light: boolean(luma(@bg) > 50%);

div {
  background: @bg; 
  color: if(@bg-light, black, white);
}

result:
div {
  background: black;
  color: white;
}

7.命名空间和访问符

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值