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两个命令来实现.这个两个命令简单易用,可满足日常需求,其实质也相当于 ...
随机推荐
- Node.js的特点
作为后端JavaScript的运行平台,Node保留了前端JavaScript中些熟悉的接口,没有改写语言本身的任何特性,依旧基于作用域和原型链,区别在于它将前端中广泛应用的思想作用到了服务器端.下面 ...
- Java:批量插入、修改数据到数据库中的用法
在java中使用JDBC实现批处理的对象一般是使用PrepareStatement对象. 如何使用: Class.forName("Oracle.jdbc.driver.OracleDriv ...
- chattr的常用参数详解
chattr的常用参数详解 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在实际生产环境中,有的运维工程师不得不和开发和测试打交道,在我们公司最常见的就是部署接口.每天每个人部署的 ...
- 记得初学JS时候练个九九乘法表都写的要死要活
还记得当初刚接触JS时候,看到视频中老师写了个九九乘法表,觉得好神奇,可是自己在下面动手写了半天还是有各种问题,甚是懊恼啊.今又看到园子里有关于乘法表的博文,出于对过去的不舍与缅怀,遂重写一遍. &l ...
- 夺命雷公狗-----React_native---4---初始化项目
我们首先在android目录下创建一个apps的文件夹: 然后我们在apps目录下,按住shift键加鼠标右键选择--在此打开命令窗口输入命令初始化项目 然后就是等了................. ...
- How to add taxonomy element to a summary view?
[re: Orchard CMS] This caused me scratching my head for days and now I can even feel it's bleeding. ...
- [liusy.api-SMJ]-MAVEN archetype 创建项目
•选择或创建工作空间 Select a workspace –File – Switch Workspace - other
- css实现三角形箭头
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- C#调用WebService (转)
1.1.Web Service基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求, ...
- Oracle 正则表达式使用示例
正则表达式的基本例子 在使用这个新功能之前,您需要了解一些元字符的含义.句号 (.) 匹配一个正规表达式中的任意字符(除了换行符).例如,正规表达式 a.b 匹配的字符串中首先包含字母 a,接着是其它 ...