less简单用法
http://less.bootcss.comless工具:koala工具url:http://koala-app.com/index-zh.html// less import:
// less 文件1 @charset 'utf-8'; //导入less文件 @import "m"; //导入css文件: //注意导入的css文件位置与编译后css的位置是一致的 @import (less) "b.css";
//m.less1 .cless{
@red:red;
color:@red;
}
//b.css1 .bcss{
color:#ccc;
}
//编译后的css文件@charset 'utf-8';
.cless {
color: #ff0000;
}
.bcss {
color: #ccc;
}
// 变量
//less文件: 1 @charset 'utf-8';
/* 这是一个编译后看见的注释*/
//这是一个编译后看不见的注释
@_width:300px;
@red:red;
.col{
//可重复声明使用不影响外调用
@red:#ccc;
color: @red;
}
.col2{
color: @red;
}
//less编译后的对应css文件:@charset 'utf-8';
/* 这是一个编译后看见的注释*/
.col {
color: #cccccc;
}
.col2 {
color: #ff0000;
}
1. 混合
.bord{
border: 1px solid #000;
}
//例:
.box{
width: @_width;
height: @_width;
background-color: @red;
.bord;//混合
}
.bord {
border: 1px solid #000;
}
.box {
width: 300px;
height: 300px;
background-color: #ff0000;
border: 1px solid #000;
}
2. 混合-带参数
.border_02(@border_width){
border: solid yellow @border_width;
}
//例:
.border_hunhe{
width: @_width;
height: @_width;
.border_02(20px);
}
.border_hunhe {
width: 300px;
height: 300px;
border: solid #ffff00 20px;
}
3.1 混合-默认值
.border_03(@border_width:10px){
border: @border_width solid green;
}
//例: 混合 不传值
.border_hunhe2{
.border_03();
}
//例: 混合 传值
.border_hunhe21{
.border_03(12px);
}
.border_hunhe2 {
border: 10px solid #008000;
}
.border_hunhe21 {
border: 12px solid #008000;
}
3.2 混合用法:默认值为变量
@bdr:10px;
.border_04(@border_width:@bdr){
border: @border_width solid @red;
}
//例: 混合 不传值
.border_hunhe3{
.border_04();
}
//例: 混合 传值
.border_hunhe31{
.border_04(13px);
}
.border_hunhe3 {
border: 10px solid #ff0000;
}
.border_hunhe31 {
border: 13px solid #ff0000;
}
4. 匹配模式
/* 三角形 border */
// 原文url:http://www.cnblogs.com/blosaa/p/3823695.html
//上
.trangle(top,@w:5px,@c:#ccc){
border-width: @w;
border-color: transparent transparent @c transparent ;
border-style: dashed dashed solid dashed ;
}
//右
.trangle(right,@w:5px,@c:#ccc){
border-width: @w;
border-color: transparent transparent transparent @c;
border-style: dashed dashed dashed solid;
}
//下
.trangle(bottom,@w:5px,@c:#ccc){
border-width: @w;
border-color:@c transparent transparent transparent;
border-style:solid dashed dashed dashed;
}
//左
.trangle(left,@w:5px,@c:#ccc){
border-width: @w;
border-color: transparent @c transparent transparent;
border-style: dashed solid dashed dashed ;
}
//匹配通用格式
.trangle(@_,@w:5px,@c:#ccc){
;
;
overflow: hidden;
}
//例:
.sanjiao{
.trangle(right,50px);
}
//例:传入错误值
.sanjiao1{
.trangle(dsa,20px);
}
/* 三角形 border */
.sanjiao {
border-width: 50px;
border-color: transparent transparent transparent #cccccc;
border-style: dashed dashed dashed solid;
width:;
height:;
overflow: hidden;
}
.sanjiao1 {
width:;
height:;
overflow: hidden;
}
5. 运算: 其中一个带单位即可注意:减法之间的格式;命名变量在运算中不可添加单位
@w10:100px;
@h10:120;
.add{
width: @w10 + 10;
height:@h10 - 10px;
color: #666 / 2; //可用,不建议
}
.add2{
width: @w10 + 12/2;
height:(@h10 - 10)*2px;
}
.add3{
width: @w10 + 10px;
height: @h10/3*3px - 6+4;
}
.add {
width: 110px;
height: 110px;
color: #333333;
}
.add2 {
width: 106px;
height: 220px;
}
.add3 {
width: 110px;
height: 118px;
}
6. 嵌套用法
ul{
width: 100px;
//margin: 10px auto;
li{
width: 100px;
float: left;
border-bottom: 1px solid #ccc /2;
}
a{
width: 100px;
color: red;
display: block;
//& 上一层选择器的名
&:hover{
color: blue;
}
span{
font-weight: bold;
font-size: 18px;
float: right;
color: #85ada7;
}
}
}
// $的用法
.tit{
width: 100px;
&_n{
width: 100px;
}
}
ul {
width: 100px;
}
ul li {
width: 100px;
float: left;
border-bottom: 1px solid #666666;
}
ul a {
width: 100px;
color: red;
display: block;
}
ul a:hover {
color: blue;
}
ul a span {
font-weight: bold;
font-size: 18px;
float: right;
color: #85ada7;
}
.tit {
width: 100px;
}
.tit_n {
width: 100px;
}
7. argument用法
.brd2(@c:#ccc,@w:10px,@solid:solid){
border:@arguments;
}
.bor2{
.brd2();
}
//注意参数对应
.bor21{
.brd2(red);
}
.bor2 {
border: #cccccc 10px solid;
}
.bor21 {
border: #ff0000 10px solid;
}
8. 避免编译
.wid{
width:~'calc(100px - 20px)';
}
.wid {
width: calc(100px - 20px);
}
9. important用法
.impor(@w:10px,@h:10px){
width:@w;
height:@h;
}
.im_a{
.impor()!important;
}
.im_a {
width: 10px !important;
height: 10px !important;
}
less简单用法的更多相关文章
- CATransition(os开发之画面切换) 的简单用法
CATransition 的简单用法 //引进CATransition 时要添加包“QuartzCore.framework”,然后引进“#import <QuartzCore/QuartzCo ...
- jquery.validate.js 表单验证简单用法
引入jquery.validate.js插件以及Jquery,在最后加上这个插件的方法名来引用.$('form').validate(); <!DOCTYPE html PUBLIC " ...
- NSCharacterSet 简单用法
NSCharacterSet 简单用法 NSCharacterSet其实是许多字符或者数字或者符号的组合,在网络处理的时候会用到 NSMutableCharacterSet *base = [NSMu ...
- [转]Valgrind简单用法
[转]Valgrind简单用法 http://www.cnblogs.com/sunyubo/archive/2010/05/05/2282170.html Valgrind的主要作者Julian S ...
- Oracle的substr函数简单用法
substr(字符串,截取开始位置,截取长度) //返回截取的字 substr('Hello World',0,1) //返回结果为 'H' *从字符串第一个字符开始截取长度为1的字符串 subst ...
- Ext.Net学习笔记19:Ext.Net FormPanel 简单用法
Ext.Net学习笔记19:Ext.Net FormPanel 简单用法 FormPanel是一个常用的控件,Ext.Net中的FormPanel控件同样具有非常丰富的功能,在接下来的笔记中我们将一起 ...
- TransactionScope简单用法
记录TransactionScope简单用法,示例如下: void Test() { using (TransactionScope scope = new TransactionScope()) { ...
- WPF之Treeview控件简单用法
TreeView:表示显示在树结构中分层数据具有项目可展开和折叠的控件 TreeView 的内容是可以包含丰富内容的 TreeViewItem 控件,如 Button 和 Image 控件.TreeV ...
- listActivity和ExpandableListActivity的简单用法
http://www.cnblogs.com/limingblogs/archive/2011/10/09/2204866.html 今天自己简单的总结了listActivity和Expandable ...
- SQL*Plus break与compute的简单用法
SQL*Plus break与compute的简单用法在SQL*Plus提示符下输出求和报表,我们可以借助break与compute两个命令来实现.这个两个命令简单易用,可满足日常需求,其实质也相当于 ...
随机推荐
- docker 服务升级
使用docker大家一般都是微服务部署了.个人的经验是乖乖的用docker自己的注册发现机制. 创建一个overlay类型的network.把所有的微服务加入进去.就可以把service name当作 ...
- Java 中 ThreadLocal 内存泄露的实例分析
前言 之前写了一篇深入分析 ThreadLocal 内存泄漏问题是从理论上分析ThreadLocal的内存泄漏问题,这一篇文章我们来分析一下实际的内存泄漏案例.分析问题的过程比结果更重要,理论结合实际 ...
- Leetcode: Concatenated Words
Given a list of words, please write a program that returns all concatenated words in the given list ...
- shell: bad interpreter: No such file or directory
执行shell脚本 错误提示如下: bash: ./back : bad interpreter:No such file or directory 因为操作系统是windows,在win ...
- 关于firewalld防火墙的使用
要想使用该防火墙,应该需要安装 networkmanager 并启动其服务.因为之前使用的是 netctl 提供的wifi-menu 来连接无线网络,导致安装networkmanager之后启动 Ne ...
- anagularJs指令的controller,link,compile有什么不同
/directives.js增加exampleDirective phonecatDirectives.directive('exampleDirective', function() { retur ...
- 浅谈Scrapy爬虫(一)
以下谈论的 scrapy 基于 0.20.2 版本(当前最新版本是 0.22.0 ),python 2.7.6. 开发环境是windows 7 sp1. 互联网上比较有价值的参考资料 1. Scr ...
- 161227、js显示对象所有属性和方法的函数
要想看到实际效果,可以先声明一些属性跟方法,否则是看不到,仔细往下看有例子的. function ShowObjProperty(Obj) { var PropertyList=''; var Pro ...
- Time crumbles things; everything grows old under the power of Time and is forgotten through the lapse of Time
Time crumbles things; everything grows old under the power of Time and is forgotten through the laps ...
- [OSG]OSG例子程序简介
1.example_osganimate一)演示了路径动画的使用(AnimationPath.AnimationPathCallback),路径动画回调可以作用在Camera.CameraView.M ...