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;">使用 & 表示当前类 </span><span style="color: #008080;"> 8</span> <span style="color: #000000;"> .box{ </span><span style="color: #008080;"> 9</span> <span style="color: #000000;"> &: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;"> &: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;">延伸 : &: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> }
Use @ to define variables. Variables can perform operations @color: #000;@width: 1000px; use & to represent the current class.box{&:hover{color: #000;}}
css can be nested
ul{display: block ;li{float : left;a{font-size : 18px;}}}
Inheritance: directly reference the class or id class where needed
.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) ;}
Mixing: Similar to functions in js, [or inheritance].layout(){...}
Scope: Restrict the conditions for inheritance, you can inherit part of a class
Extension: &:extend(. box); Multiple class names can be filled in the brackets. The compiled effect is the grouping in CSS
when is used to make conditional judgments
when not not equal to
/* Use isnumber to determine whether a parameter is a number * */
.border(@width : 1px , @style : solid, @color : #d1d1d1) when (isnumber(@width)){ border: @width @style @color;}
/* Use iscolor to determine whether a parameter is Color * */
.border(@color) when (iscolor(@color)){ .border(1px , solid , @color);}
.border(@solid) when not ( iscolor(@solid)) , ( isnumber(@solid) ){ .border(1px , @solid);}

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.
