CSS_LESS 文法/函數詳解

來源:互聯網
上載者:User

嵌套規則

01 #header { colorblack; }#header .navigation {  font-size12px;
02 }#header .logo { 
03   width300px
04 }#header .logo:hover {  text-decorationnone;
05 }
06  
07 #header {  colorblack;  .navigation {    font-size12px;
08   }  .logo {    width300px;
09     &:hover { text-decorationnone }
10   }
11 }

 

變數:

1 @nice-blue: #5B83AD;
2 @light-blue: @nice-blue #111;
3 #header { color: @light-blue; }

 

偽類寫法:

1 a{
2     colorred;
3     &:hover{color:blue;}
4     &:active{color:green;}
5 }

 

COLOR顏色函數:

01 lighten(@color, 10%);     // return a color which is 10% *lighter* than @color
02 darken(@color, 10%);      // return a color which is 10% *darker* than @color
03  
04 saturate(@color, 10%);    // return a color 10% *more* saturated than @color
05 desaturate(@color, 10%);  // return a color 10% *less* saturated than @color
06  
07 fadein(@color, 10%);      // return a color 10% *less* transparent than @color
08 fadeout(@color, 10%);     // return a color 10% *more* transparent than @color
09 fade(@color, 50%);        // return @color with 50% transparency
10  
11 spin(@color, 10);         // return a color with a 10 degree larger in hue than @color
12 spin(@color, -10);        // return a color with a 10 degree smaller hue than @color
13  
14 mix(@color1, @color2);    // return a mix of @color1 and @color2

 

 

DEMO_HTML:

Google/Firefox瀏覽器適用,IE瀏覽器不相容.

01 <!doctype html>
02 <html>
03 <head>
04     <meta charset="UTF-8">
05     <title>Document</title>
06     <link rel="stylesheet/less" type="text/css" href="less/styles.less" />
07     <script src="less-1.5.0.min.js" type="text/javascript"></script>
08 </head>
09 <body>
10     <div id="content">
11         <div style="height:30px;color:#FFF;background-color:#000;">對照文本顏色</div>
12         <h1>這裡是標題啦</h1>
13         <h2>內容標題檔案</h2>
14         <h3>再一種顏色</h3>
15         <p>一種新顏色</p>
16     </div>
17 <script>
18     less.watch(); //自動重新整理
19 </script>
20 </body>
21 </html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.