Less为css预处理器

首先先去下载一个koala编译器软件,然后运行打开

新建一个项目目录,在css文件夹中新建一个后缀为less的文件,然后拉入koala软件中,然后运行

,你的css文件夹中就会多出一个css文件

然后就可以编写less文件了,编写过程中可以在css文件里查看详细信息。

以下是less文件的知识点

@charset "utf-8";
/*会被编译*/
//不会被编译
@test_width:500px;
@test_height:500px;
body{
background-color: #ccc;
}
/*混合*/
.box{
width:@test_width;
height: @test_height;
background-color:yellow;
.border;
}
.border{
border:5px solid pink;
}
.box2{
.box;
margin-top:50px;
}
/*混合-可带参数*/
.border_02(@border_width){
border:solid #000 @border_width;
}
.test_hunhe{
.border_02(30px);
}
/*混合-默认带参数*/
.border_03(@border_width:40px){
border:solid #000 @border_width;
}
.test_hunhe2{
.border_03(20px);
}
/*混合的例子*/
.border_radius(@raidus:5px){
-webkit-border-radius: @raidus;
-moz-border-radius: @raidus;
border-radius: @raidus;
}
.radius_test{
width: 100px;
height: 40px;
background-color:green;
.border_radius(10px);
}
//普通写法
/*.sanjiao{
width: 0;
height: 0;
overflow: hidden;
border-width: 10px;
border-color:transparent transparent transparent red;
border-style:dashed dashed dashed solid; //dashed解决ie有背景的问题
}*/
/*匹配模式*/
//边框实现三角形
.triangle(left,@w:50px,@c:#f00){
border-width: @w;
border-color: transparent transparent transparent @c;
border-style: dashed dashed dashed solid;
}
.triangle(right,@w:50px,@c:#f00){
border-width: @w;
border-color: transparent @c transparent transparent ;
border-style: dashed solid dashed dashed ;
}
.triangle(top,@w:50px,@c:#f00){
border-width: @w;
border-color:@c transparent transparent transparent ;
border-style: solid dashed dashed dashed;
}
.triangle(bottom,@w:50px,@c:#f00){
border-width: @w;
border-color: transparent transparent @c transparent ;
border-style: dashed dashed solid dashed ;
}
.triangle(@_,@w:50px,@c:#f00){
width: 0;
height: 0;
overflow: hidden;
}
.sanjiao{
.triangle(right);
}
/*匹配模式-定位例子*/
.pos(r){
position: relative;
}
.pos(f){
position:fixed;
}
.pos(a){
position:absolute;
}
.pos(s){
position:statice;
}
.pipei{
width: 50px;
height: 50px;
left: 0;
top: 0;
background-color: #0f0;
.pos(f);
}
/*运算*/
@test_01:300px;
.box_02{
width:(@test_01 - 20)*5;
}
/*嵌套*/
.list{
width: 600px;
margin: 30px auto;
padding: 0;
list-style: none;
li{
height: 30px;
line-height: 30px;
background-color: pink;
margin-bottom: 5px;
padding: 0 10px;
}
a{
float:left;
//& 代表他的上一层选择器
&:hover{
color:#FF0000;
}
}
span{
float:right;
}

}
/*@arguments*/
.border_arg(@w:30px,@c:red,@xx:solid){
border:@arguments;
}
.test_arguments{
.border_arg(40px);
}
/*避免编译*/
.test_03{
width:~'calc(300px - 30px)';
}

//!important
.test_arguments{
.border_arg(40px) !important;
}

花了几个小时终于搞定了,还有待实践;

随机推荐

  1. 成吨提高开发效率:Intellij Shortcuts精简子集与思维模式

    在线精简cheatsheet备查表:intellij.linesh.twGithub项目:intellij-mac-frequent-keymap Intellij的快捷键多而繁杂,从官方推荐的key ...

  2. Redis命令拾遗五(有序集合)

    本文版权归博客园和作者吴双本人共同所有,博客园蜗牛NoSql系列分享 http://www.cnblogs.com/tdws/tag/NoSql/ Sorted Set 有序集合—Sorted Set ...

  3. 搭建公司内部的NuGet Server

    随着公司业务慢慢的拓展,项目便会越来越来多,很多项目会依赖其他项目DLL,比如一些底层的技术框架DLL引用,还有各业务系统的也有可能会有引用的可能. 项目多,交叉引用多,如果要是有一个DLL更新,那就 ...

  4. App内测神器之蒲公英

    一.前言部分 没使用蒲公英之前一直采用非常傻B的方式给公司App做内部测试,要么发个测试包让公司测试人员用iTUnes 自己安装 要么苦逼的一个个在我Xcode上直接安装测试包,操作起来又麻烦又苦逼, ...

  5. C语言实现2个大数相加。

    #include<stdio.h>#include<string.h>int main(){    char s1[100],s2[100];    int num1[31], ...

  6. 让IIS7.0.0.0支持 .iso .7z .torrent .apk等文件下载的设置方法

    IIS默认支持哪些MIME类型呢,我们可以这样查看:打开IIS管理器(计算机--管理--服务和应用程序--Internet信息服务(IIS)管理器:或者Win+R,输入inetmgr,Enter),在 ...

  7. swift 如何在IOS应用图标上添加消息数

    在应用图标右上角添加消息数提醒,可以很方便的告知用户该应用中有无新消息需要处理.下面用xcode 7.3.1来简要说明一下如何用swift语言进行此功能的实现. 1.修改 AppDelegate.sw ...

  8. ArcGIS Engine开发之地图浏览

    地图的浏览功能包括缩放.移动.量测旋转等. 1.放大与缩小 无论是放大还是缩小,都是通过改变MapControl中当前视图的范围Extent属性来实现的,主要用到包络线(Envelope)类. 包络线 ...

  9. iOS 设置UILabel的行间距并自适应高度

    NSString *contentStr = @"总以为,在最初的地方,有一个最原来的我,就也会有一个最原来的你"; UILabel *tempLabel = [[UILabel ...

  10. javaScript对象-基本包装类型的详解

    本人按书上的内容大致地把javaScript对象划分成“引用类型”.“基本包装类型”和“内置对象”三块内容. 我们这篇先了解下基本包装类型的详细用法吧! 一.我们先解下相关概念: 1.引用类型的值(对 ...