less 实战

less 实战

安装

npm install -g less
lessc styles.less styles.css 

编译

lessc style.less style.css

$ lessc style.less style.css --clean-css="advanced"

方法使用

嵌套

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

.clearfix {
  display: block;
  zoom: 1;

  &:after {
    content: " ";
    display: block;
    font-size: 0;
    height: 0;
    clear: both;
    visibility: hidden;
  }
}

运算

@other: @base + @filler; // result is 15%

@var: 50vh/2;
width: calc(50% + (@var - 20px));  // result is calc(50% + (25vh - 20px))

导入

@import "typo.css";

函数

// 定义方法- 传入参数@index
.color-list (@index:1) {
    @list:#b8efb1,#50b543,#fda496,#ea3f2d;
    background-color: extract(@list,@index)
}
.color01 span{ .color-list(1) }
.color02 span{ .color-list(2) }
.color03 span{ .color-list(3) }
.color04 span{ .color-list(4) }

转载于:https://www.cnblogs.com/dreamone/p/9105607.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值