成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專(zhuān)欄INFORMATION COLUMN

less使用特性-Mixins

RyanQ / 3434人閱讀

摘要:命名參數(shù)變量函數(shù)循環(huán)合并逗號(hào)括號(hào)

1. Mixins 1.1 Selectors in Mixins
.my-hover-mixin() {
  &:hover {
    border: 1px solid red;
  }
}
button {
  .my-hover-mixin();
}

output:

button:hover {
  border: 1px solid red;
}
1.2 The !important keyword
.foo (@bg: #f5f5f5, @color: #900) {
  background: @bg;
  color: @color;
}
.unimportant {
  .foo();
}
.important {
  .foo() !important;
}

output:

.unimportant {
  background: #f5f5f5;
  color: #900;
}
.important {
  background: #f5f5f5 !important;
  color: #900 !important;
}
1.3 Parametric Mixins
.border-radius(@radius) {
  -webkit-border-radius: @radius;
     -moz-border-radius: @radius;
          border-radius: @radius;
}

#header {
  .border-radius(4px);
}
.button {
  .border-radius(6px);
}

.border-radius(@radius: 5px) {
  -webkit-border-radius: @radius;
     -moz-border-radius: @radius;
          border-radius: @radius;
}

#header {
  .border-radius;
}
1.4 命名參數(shù)
.mixin(@color: black; @margin: 10px; @padding: 20px) {
  color: @color;
  margin: @margin;
  padding: @padding;
}
.class1 {
  .mixin(@margin: 20px; @color: #33acfe);
}
.class2 {
  .mixin(#efca44; @padding: 40px);
}

output: 
.class1 {
  color: #33acfe;
  margin: 20px;
  padding: 20px;
}
.class2 {
  color: #efca44;
  margin: 10px;
  padding: 40px;
}
1.5 arguments 變量
.box-shadow(@x: 0; @y: 0; @blur: 1px; @color: #000) {
  -webkit-box-shadow: @arguments;
     -moz-box-shadow: @arguments;
          box-shadow: @arguments;
}
.big-block {
  .box-shadow(2px; 5px);
}

output:

.big-block {
  -webkit-box-shadow: 2px 5px 1px #000;
     -moz-box-shadow: 2px 5px 1px #000;
          box-shadow: 2px 5px 1px #000;
}
1.6 函數(shù)
.average(@x, @y) {
  @average: ((@x + @y) / 2);
}

div {
  .average(16px, 50px); // "call" the mixin
  padding: @average;    // use its "return" value
}

output:

div {
  padding: 33px;
}
循環(huán)
.generate-columns(4);

.generate-columns(@n, @i: 1) when (@i =< @n) {
  .column-@{i} {
    width: (@i * 100% / @n);
  }
  .generate-columns(@n, (@i + 1));
}

output:

.column-1 {
  width: 25%;
}
.column-2 {
  width: 50%;
}
.column-3 {
  width: 75%;
}
.column-4 {
  width: 100%;
}
合并 逗號(hào)
.mixin() {
  box-shadow+: inset 0 0 10px #555;
}
.myclass {
  .mixin();
  box-shadow+: 0 0 20px black;
}

output:

.myclass {
  box-shadow: inset 0 0 10px #555, 0 0 20px black;
}
括號(hào)
.mixin() {
  transform+_: scale(2);
}
.myclass {
  .mixin();
  transform+_: rotate(15deg);
}

output:

.myclass {
  transform: scale(2) rotate(15deg);
}

文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請(qǐng)注明本文地址:http://systransis.cn/yun/111504.html

相關(guān)文章

  • 大話(huà)css預(yù)編譯處理(三):基礎(chǔ)語(yǔ)法篇

    摘要:值得慶幸的是,這三款預(yù)處理器語(yǔ)言的語(yǔ)法和語(yǔ)法都差不多。在這一節(jié)中,我們依次來(lái)對(duì)比一下這三款預(yù)處理器語(yǔ)言各種特性的異同之處,以及使用方法。預(yù)處理器語(yǔ)言支持任何變量例如顏色數(shù)值文本。 一、Sass、LESS和Stylus的語(yǔ)法 每一種語(yǔ)言都有自己一定的語(yǔ)法規(guī)則,CSS預(yù)處理器語(yǔ)言也不例外,在真正使用CSS預(yù)處器語(yǔ)言之前還有一個(gè)不可缺少的知識(shí)點(diǎn),就是對(duì)語(yǔ)法的理解。值得慶幸的是,這三款CSS預(yù)...

    劉東 評(píng)論0 收藏0
  • less學(xué)習(xí)之Bootstrap(按鈕篇)

    摘要:學(xué)習(xí)之按鈕篇如我上一篇學(xué)習(xí)之里面,介紹了的目錄結(jié)構(gòu),說(shuō)明了在這個(gè)文件里面,定義了主題色,也包括了按鈕的主題色。偽連接,按鈕的樣式顯示為連接的樣式。接下來(lái)的安排,自己寫(xiě)的文章自己也會(huì)去實(shí)現(xiàn)它,另外關(guān)于的學(xué)習(xí)也不會(huì)停止。 less學(xué)習(xí)之Bootstrap按鈕篇) 如我上一篇less學(xué)習(xí)之Bootstrap里面,介紹了Bootstrap的目錄結(jié)構(gòu),說(shuō)明了在variables.less這個(gè)文件...

    sherlock221 評(píng)論0 收藏0
  • 前端入門(mén)23-CSS預(yù)處理器(Less&Sass)

    摘要:聲明聲明本篇內(nèi)容梳理自以下幾個(gè)來(lái)源網(wǎng)站的文檔中文網(wǎng)感謝大佬們的分享。這個(gè)時(shí)候,預(yù)處理器就出現(xiàn)了,其實(shí)應(yīng)該是說(shuō)和這類(lèi)語(yǔ)言出現(xiàn)了。聲明 本篇內(nèi)容梳理自以下幾個(gè)來(lái)源: Github:smyhvae/web Bootstrap網(wǎng)站的 less 文檔 Sass中文網(wǎng) 感謝大佬們的分享。 正文-CSS預(yù)處理(less&Sass) CSS預(yù)處理 什么是 CSS 預(yù)處理?為什么要有 CSS 預(yù)處理? 這...

    freecode 評(píng)論0 收藏0
  • less 使用特性-變量

    1. 變量 @nice-blue: #5B83AD; @light-blue: @nice-blue + #111; #header { color: @light-blue; } output: #header { color: #6c94be; } 1.1. 選擇器 // Variables @my-selector: banner; // Usage .@{my-select...

    xbynet 評(píng)論0 收藏0

發(fā)表評(píng)論

0條評(píng)論

最新活動(dòng)
閱讀需要支付1元查看
<