search

<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);}

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is the difference between an HTML tag and an HTML attribute?What is the difference between an HTML tag and an HTML attribute?May 14, 2025 am 12:01 AM

HTMLtagsdefinethestructureofawebpage,whileattributesaddfunctionalityanddetails.1)Tagslike,,andoutlinethecontent'splacement.2)Attributessuchassrc,class,andstyleenhancetagsbyspecifyingimagesources,styling,andmore,improvingfunctionalityandappearance.

The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.