less

Sep 29, 2016 am 09:19 AM
less

<span style="color: #008080;"> 1</span> <span style="color: #000000;">使用 @ 定义变量
</span><span style="color: #008080;"> 2</span> <span style="color: #000000;">    变量可以做运算
</span><span style="color: #008080;"> 3</span>     
<span style="color: #008080;"> 4</span> <span style="color: #000000;">    @color : #000;
</span><span style="color: #008080;"> 5</span> <span style="color: #000000;">    @width : 1000px;
</span><span style="color: #008080;"> 6</span>     
<span style="color: #008080;"> 7</span> <span style="color: #000000;">使用 &amp; 表示当前类
</span><span style="color: #008080;"> 8</span> <span style="color: #000000;">    .box{
</span><span style="color: #008080;"> 9</span> <span style="color: #000000;">        &amp;:hover{
</span><span style="color: #008080;">10</span> <span style="color: #000000;">            color : #000;
</span><span style="color: #008080;">11</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">12</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">13</span> 
<span style="color: #008080;">14</span> <span style="color: #000000;">css 可以嵌套
</span><span style="color: #008080;">15</span> 
<span style="color: #008080;">16</span> <span style="color: #000000;">    ul{
</span><span style="color: #008080;">17</span> <span style="color: #000000;">        display : block;
</span><span style="color: #008080;">18</span> <span style="color: #000000;">        li{
</span><span style="color: #008080;">19</span> <span style="color: #000000;">            float : left;
</span><span style="color: #008080;">20</span> <span style="color: #000000;">            a{
</span><span style="color: #008080;">21</span> <span style="color: #000000;">                font-size : 18px;
</span><span style="color: #008080;">22</span> <span style="color: #000000;">            }
</span><span style="color: #008080;">23</span> <span style="color: #000000;">        }
</span><span style="color: #008080;">24</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">25</span> 
<span style="color: #008080;">26</span> <span style="color: #000000;">继承 : 直接在需要的地方引用 class或者 id 类
</span><span style="color: #008080;">27</span> 
<span style="color: #008080;">28</span> <span style="color: #000000;">.clearfix{
</span><span style="color: #008080;">29</span> <span style="color: #000000;">    zoom : 1;
</span><span style="color: #008080;">30</span> <span style="color: #000000;">    display : block;
</span><span style="color: #008080;">31</span> <span style="color: #000000;">    &amp;:after{
</span><span style="color: #008080;">32</span> <span style="color: #000000;">        content: "";
</span><span style="color: #008080;">33</span> <span style="color: #000000;">        visibility: hidden;
</span><span style="color: #008080;">34</span> <span style="color: #000000;">        clear: both;
</span><span style="color: #008080;">35</span> <span style="color: #000000;">        height: 0;
</span><span style="color: #008080;">36</span> <span style="color: #000000;">        display: block;
</span><span style="color: #008080;">37</span> <span style="color: #000000;">    }
</span><span style="color: #008080;">38</span> <span style="color: #000000;">}
</span><span style="color: #008080;">39</span> 
<span style="color: #008080;">40</span> <span style="color: #000000;">.radius(@radius : 15px){
</span><span style="color: #008080;">41</span> <span style="color: #000000;">    border-radius: @radius;
</span><span style="color: #008080;">42</span> <span style="color: #000000;">}
</span><span style="color: #008080;">43</span> 
<span style="color: #008080;">44</span> <span style="color: #000000;">.box{
</span><span style="color: #008080;">45</span> <span style="color: #000000;">    .clearfix;
</span><span style="color: #008080;">46</span> <span style="color: #000000;">    .radius(10px);
</span><span style="color: #008080;">47</span> <span style="color: #000000;">}
</span><span style="color: #008080;">48</span> 
<span style="color: #008080;">49</span> <span style="color: #000000;">混合 : 类似 js 中的函数, [或者叫继承]
</span><span style="color: #008080;">50</span> <span style="color: #000000;">.layout(){
</span><span style="color: #008080;">51</span> <span style="color: #000000;">    ...
</span><span style="color: #008080;">52</span> <span style="color: #000000;">}
</span><span style="color: #008080;">53</span> 
<span style="color: #008080;">54</span> 
<span style="color: #008080;">55</span> <span style="color: #000000;">作用域 : 限制继承的条件,可以继承一个 类的部分内容
</span><span style="color: #008080;">56</span> 
<span style="color: #008080;">57</span> <span style="color: #000000;">延伸 : &amp;:extend(.box); 括号中可以填写多个 类名  编译后的效果就是 css 中的分组
</span><span style="color: #008080;">58</span> 
<span style="color: #008080;">59</span> 
<span style="color: #008080;">60</span> <span style="color: #000000;">when 用来做条件判断
</span><span style="color: #008080;">61</span> 
<span style="color: #008080;">62</span> <span style="color: #000000;">when not 不等于
</span><span style="color: #008080;">63</span> 
<span style="color: #008080;">64</span> <span style="color: #000000;">/*
</span><span style="color: #008080;">65</span> <span style="color: #000000;">    使用 isnumber 来判断某个参数是否为 数字
</span><span style="color: #008080;">66</span> <span style="color: #000000;"> * */
</span><span style="color: #008080;">67</span> 
<span style="color: #008080;">68</span> <span style="color: #000000;">.border(@width : 1px , @style : solid, @color : #d1d1d1) when (isnumber(@width)){
</span><span style="color: #008080;">69</span> <span style="color: #000000;">    border: @width @style @color;
</span><span style="color: #008080;">70</span> <span style="color: #000000;">}
</span><span style="color: #008080;">71</span> 
<span style="color: #008080;">72</span> <span style="color: #000000;">/*
</span><span style="color: #008080;">73</span> <span style="color: #000000;">    使用 iscolor 来判断某个参数是否为 颜色
</span><span style="color: #008080;">74</span> <span style="color: #000000;"> * */
</span><span style="color: #008080;">75</span> 
<span style="color: #008080;">76</span> <span style="color: #000000;">.border(@color) when (iscolor(@color)){
</span><span style="color: #008080;">77</span>     
<span style="color: #008080;">78</span> <span style="color: #000000;">    .border(1px , solid , @color);
</span><span style="color: #008080;">79</span> <span style="color: #000000;">}
</span><span style="color: #008080;">80</span> 
<span style="color: #008080;">81</span> 
<span style="color: #008080;">82</span> <span style="color: #000000;">.border(@solid) when not ( iscolor(@solid)) , ( isnumber(@solid) ){
</span><span style="color: #008080;">83</span> <span style="color: #000000;">    .border(1px , @solid);
</span><span style="color: #008080;">84</span> }
Copier après la connexion

 

使用 @ 定义变量变量可以做运算@color : #000;@width : 1000px;使用 & 表示当前类.box{&:hover{color : #000;}}
css 可以嵌套
ul{display : block;li{float : left;a{font-size : 18px;}}}
继承 : 直接在需要的地方引用 class或者 id 类
.clearfix{zoom : 1;display : block;&:after{content: "";        visibility: hidden;        clear: both;        height: 0;        display: block;}}
.radius(@radius : 15px){border-radius: @radius;}
.box{.clearfix;.radius(10px);}
混合 : 类似 js 中的函数, [或者叫继承].layout(){...}

作用域 : 限制继承的条件,可以继承一个 类的部分内容
延伸 : &:extend(.box); 括号中可以填写多个 类名  编译后的效果就是 css 中的分组

when 用来做条件判断
when not 不等于
/*    使用 isnumber 来判断某个参数是否为 数字 * */
.border(@width : 1px , @style : solid, @color : #d1d1d1) when (isnumber(@width)){    border: @width @style @color;}
/*    使用 iscolor 来判断某个参数是否为 颜色 * */
.border(@color) when (iscolor(@color)){        .border(1px , solid , @color);}

.border(@solid) when not ( iscolor(@solid)) , ( isnumber(@solid) ){    .border(1px , @solid);}

Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn

Article chaud

Repo: Comment relancer ses coéquipiers
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
1 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: Comment obtenir des graines géantes
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
Combien de temps faut-il pour battre Split Fiction?
3 Il y a quelques semaines By DDD

Article chaud

Repo: Comment relancer ses coéquipiers
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Crystals d'énergie expliqués et ce qu'ils font (cristal jaune)
1 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: Comment obtenir des graines géantes
3 Il y a quelques semaines By 尊渡假赌尊渡假赌尊渡假赌
Combien de temps faut-il pour battre Split Fiction?
3 Il y a quelques semaines By DDD

Tags d'article chaud

Bloc-notes++7.3.1

Bloc-notes++7.3.1

Éditeur de code facile à utiliser et gratuit

SublimeText3 version chinoise

SublimeText3 version chinoise

Version chinoise, très simple à utiliser

Envoyer Studio 13.0.1

Envoyer Studio 13.0.1

Puissant environnement de développement intégré PHP

Dreamweaver CS6

Dreamweaver CS6

Outils de développement Web visuel

SublimeText3 version Mac

SublimeText3 version Mac

Logiciel d'édition de code au niveau de Dieu (SublimeText3)

Difficulté à mettre à jour la mise en cache des pages Web officielles du compte: comment éviter l'ancien cache affectant l'expérience utilisateur après la mise à jour de la version? Difficulté à mettre à jour la mise en cache des pages Web officielles du compte: comment éviter l'ancien cache affectant l'expérience utilisateur après la mise à jour de la version? Mar 04, 2025 pm 12:32 PM

Difficulté à mettre à jour la mise en cache des pages Web officielles du compte: comment éviter l'ancien cache affectant l'expérience utilisateur après la mise à jour de la version?

Comment utiliser les attributs de validation du formulaire HTML5 pour valider l'entrée utilisateur? Comment utiliser les attributs de validation du formulaire HTML5 pour valider l'entrée utilisateur? Mar 17, 2025 pm 12:27 PM

Comment utiliser les attributs de validation du formulaire HTML5 pour valider l'entrée utilisateur?

Comment ajouter efficacement les effets de course aux images PNG sur les pages Web? Comment ajouter efficacement les effets de course aux images PNG sur les pages Web? Mar 04, 2025 pm 02:39 PM

Comment ajouter efficacement les effets de course aux images PNG sur les pages Web?

Quel est le but du & lt; iframe & gt; étiqueter? Quelles sont les considérations de sécurité lorsque vous l'utilisez? Quel est le but du & lt; iframe & gt; étiqueter? Quelles sont les considérations de sécurité lorsque vous l'utilisez? Mar 20, 2025 pm 06:05 PM

Quel est le but du & lt; iframe & gt; étiqueter? Quelles sont les considérations de sécurité lorsque vous l'utilisez?

Quel est le but du & lt; mètre & gt; élément? Quel est le but du & lt; mètre & gt; élément? Mar 21, 2025 pm 12:35 PM

Quel est le but du & lt; mètre & gt; élément?

Quel est le but du & lt; datalist & gt; élément? Quel est le but du & lt; datalist & gt; élément? Mar 21, 2025 pm 12:33 PM

Quel est le but du & lt; datalist & gt; élément?

Quelles sont les meilleures pratiques pour la compatibilité entre les navigateurs dans HTML5? Quelles sont les meilleures pratiques pour la compatibilité entre les navigateurs dans HTML5? Mar 17, 2025 pm 12:20 PM

Quelles sont les meilleures pratiques pour la compatibilité entre les navigateurs dans HTML5?

Comment utiliser efficacement les liens HTML pour la navigation et le référencement? Comment utiliser efficacement les liens HTML pour la navigation et le référencement? Mar 18, 2025 pm 02:39 PM

Comment utiliser efficacement les liens HTML pour la navigation et le référencement?

See all articles