LESS之语法

LESS

less是一门向后兼容的css语法扩展语言

变量

1 声明

以‘@’来声明

styles.less

// css样式
@WIDTH: 100px;
@HEIGHT: @WIDTH + 10px;
@FontSize: 12px;
@LetterSpacing: @FontSize * 1.38;
// 选择器
@circelSelector: circel;
.@{circelSelector} {
    border-radius:  50%;
}
@pointerSelector: pointer;
.@{pointerSelector} {
    cursor: pointer;
}
// 路径
@images: '../../assets/images/';

dome.less

// 文件名
@file: "../../";
@import '@{file}styles.less';
// 颜色定义
@font-color: pink;
@dark-font-color: darken(@font-color, 15%);
p {
    height: @HEIGHT;
    font-size: @FontSize * 3;
    color: @font-color;
    transition: color .50s ease-in;
    letter-spacing: @LetterSpacing * 3;
}
p:hover{
    color: @dark-font-color;
    transition: color .50s ease-in;
}
.header{
    @width: 500px;
    width: @width;
    height: @width;
    background: url("@{images}h_f.jpg") no-repeat left top/cover;
}

Mixins

.bgImg() {
  background-position: left top;
  background-repeat: no-repeat;
  background-size: cover;
}
.border-radius(@radius: 5px) {
  -webkit-border-radius: @radius;
     -moz-border-radius: @radius;
          border-radius: @radius;
}
.square(@width, @height) {
    width: @width;
    height:  @height;
}
.box-shadow(@x: 0; @y: 0; @blur: 1px; @color: #000) {
  -webkit-box-shadow: @arguments;
     -moz-box-shadow: @arguments;
          box-shadow: @arguments;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值