码迷,mamicode.com
首页 > 其他好文 > 详细

Less 的用法

时间:2018-05-05 11:12:38      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:href   例子   tag   port   yellow   技术分享   技术   oat   top   

1. node.js

node.js是一个前端的框架 自带一个包管理工具npm

  • node.js 的安装

官网:http://nodejs.cn/

技术分享图片

技术分享图片技术分享图片技术分享图片技术分享图片

技术分享图片

  • 在命令行检验是否安装成功

技术分享图片

  • 切换到项目目录,初始化了一个package.json文件

技术分享图片

  • 安装与卸载jQuery包(例子)
    •   安装

技术分享图片

    •   卸载

技术分享图片

  • 安装淘宝镜像

技术分享图片

2. 安装less

技术分享图片

技术分享图片

3. less 的基本用法

https://less.bootcss.com/

  •  变量
@red:red;
@w:200px;
#big{
    width:@w;
    height:@w;
    background-color:@red;
    #small{
        width:@w;
        height:@w;
        background-color:@red;
    }
}
p{
    color:@red;
}
  • 混合
.bt{
    width:200px;
    height:200px;
    border-top:2px solid red;
    background-color:red;
}
#big{
    .bt;
    #small{
        .bt;
    }
}
  • 嵌套
#box{
    width:100%;
    height:60px;
    background-color:#ccc;
    h3{
        width:100%;
        height:20px;
        background-color:yellow;
    }
    ul{
        list-style:none;     
        li{
            height:40px;
            line-height:40px;
            float:left;
            padding:0 10px;
        }
    }
}
  • 运算
@color:#333;
#box{
    width:100%;
    height:60px;
    background-color:@color+#111;
}
  • calc()
@var:50vh/2;
#box{
    width:calc(50% + (@var - 20px));
}
  • 固定函数
@base:#f04615;
@width:0.5;
#box{
    width:percentage(@width);
    color:saturate(@base,5%);
    background-color:spin(lighten(@base,25%),8);
}
  • 注释
//单行注释//
/*多行
  注释*/
  • 引入其他less文件
@import "other.less";

 

Less 的用法

标签:href   例子   tag   port   yellow   技术分享   技术   oat   top   

原文地址:https://www.cnblogs.com/writerW/p/8984610.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!