Lesson-30 less

2015-11-17  本文已影响95人  阿瑟李
.rounded-corners (@radius: 5px) {
   border-radius: @radius;
   -webkit-border-radius: @radius;
   -moz-border-radius: @radius;
}
#header {
   .rounded-corners;
} 
#footer {
   .rounded-corners(10px);
} 
a { text-decoration: none;
     &:hover { border-width: 1px }
   }
下面就是常见的检测函式:
iscolor
isnumber
isstring
iskeyword
isurl
如果你想判断一个值是纯数字,还是某个单位量,可以使用下列函式:
ispixel
ispercentage
isem
lighten(@color, 10%);     // return a color which is 10% *lighter* than @color
darken(@color, 10%);      // return a color which is 10% *darker* than @color
saturate(@color, 10%);    // return a color 10% *more* saturated than @color
desaturate(@color, 10%);  // return a color 10% *less* saturated than @color
fadein(@color, 10%);      // return a color 10% *less* transparent than @color
fadeout(@color, 10%);     // return a color 10% *more* transparent than @color
fade(@color, 50%);        // return @color with 50% transparency
spin(@color, 10);         // return a color with a 10 degree larger in hue than @color
spin(@color, -10);        // return a color with a 10 degree smaller hue than @color
mix(@color1, @color2);    // return a mix of @color1 and @color2
round(1.67); // returns `2`
ceil(2.4);   // returns `3`
floor(2.6);  // returns `2`
percentage(0.5); // returns `50%`
#bundle {
 .button () {
   display: block;
   border: 1px solid black;
   background-color: grey;
   &:hover { background-color: white }
 }
 ...
}
#header a {
 color: orange;
 #bundle > .button;
}
@import "lib.less";
@import "lib";
@base-url: "http://assets.fnord.com";
background-image: url("@{base-url}/images/bg.png");
上一篇下一篇

猜你喜欢

热点阅读