
{"id":1611,"date":"2020-07-29T13:31:15","date_gmt":"2020-07-29T05:31:15","guid":{"rendered":"http:\/\/admin.evshou.com\/?p=1611"},"modified":"2020-08-07T16:08:35","modified_gmt":"2020-08-07T08:08:35","slug":"web%e5%89%8d%e7%ab%af%ef%bc%9asass%e5%92%8cless","status":"publish","type":"post","link":"https:\/\/www.9713job.com\/?p=1611","title":{"rendered":"web\u524d\u7aef\uff1aSass\u548cLess"},"content":{"rendered":"<h3>Sass\u548cLess<\/h3>\n<p>Sass\u548cLess\u90fd\u5c5e\u4e8eCSS\u9884\u5904\u7406\u5668\uff0cCSS\u9884\u5904\u7406\u5668\u5b9a\u4e49\u4e86\u4e00\u79cd\u65b0\u7684\u8bed\u8a00\uff0c\u5176\u57fa\u672c\u601d\u60f3\u662f\uff0c\u7528\u4e00\u79cd\u4e13\u95e8\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u4e3aCSS\u589e\u52a0\u4e86\u4e00\u4e9b\u7f16\u7a0b\u7684\u7279\u6027\uff0c<br \/>\n\u5982\uff1a\u53d8\u91cf\u3001\u8bed\u53e5\u3001\u51fd\u6570\u3001\u7ee7\u627f\u7b49\u6982\u5ff5\u3002<br \/>\n\u5c06CSS\u4f5c\u4e3a\u76ee\u6807\u751f\u6210\u6587\u4ef6\uff0c\u7136\u540e\u5f00\u53d1\u8005\u5c31\u53ea\u8981\u4f7f\u7528\u8fd9\u79cd\u8bed\u8a00\u8fdb\u884cCSS\u7684\u7f16\u7801\u5de5\u4f5c\u3002<br \/>\nSass\u540e\u7f00\u540d.scss<br \/>\nLess\u540e\u7f00\u540d.less<\/p>\n<p>\u8bed\u6cd5\uff1a<!--more--><\/p>\n<p>\u6ce8\u91ca<br \/>\ncss\u5355\u884c\u6ce8\u91ca\u4e0d\u4f1a\u88ab\u7f16\u8bd1\u51fa\u6765\uff0c\u591a\u884c\u6ce8\u91ca\u4f1a\u88ab\u7f16\u8bd1\u51fa\u6765<\/p>\n<p>\u53d8\u91cf<br \/>\nLess\u53d8\u91cf @number:123px;<br \/>\nSass\u53d8\u91cf $number:123px;<\/p>\n<p>\u63d2\u503c<br \/>\nLess @key:margin;<br \/>\n@{key}:auto;<br \/>\nSass $key:margin;<br \/>\n#{$key}:auto;<\/p>\n<p>\u4f5c\u7528\u57df<br \/>\nLess:<br \/>\n@number:123px;<br \/>\n.box3{@number:456px;width:@number;\/\/456px}<\/p>\n<p>Sass:\u4f5c\u7528\u57df\u6709\u987a\u5e8f\u7684<br \/>\n$number:123px;<br \/>\n.box3{$number:456px;width:@number;height:@number;\/\/456px}<\/p>\n<p>\u9009\u62e9\u5668\u5d4c\u5957<br \/>\nul{<br \/>\nlist-style:none;<br \/>\nli{<br \/>\nfloat:left;<br \/>\ndiv{margin:20px;}<br \/>\np{margin:20px;}<br \/>\n}<br \/>\n}<\/p>\n<p>\u4f2a\u7c7b\u5d4c\u5957<br \/>\nul{<br \/>\nlist-style:none;<br \/>\nli{<br \/>\nfloat:left;<br \/>\ndiv{margin:20px;}<br \/>\np{margin:20px;}<br \/>\n}<br \/>\n&amp;:hover{color:red;\/\/&amp;\u53bb\u9664ul\u540e\u9762\u7684\u7a7a\u683c}<br \/>\n}<\/p>\n<p>\u5c5e\u6027\u5d4c\u5957Sass,Less\u4e0d\u652f\u6301<br \/>\nul{<br \/>\nlist-style:none;<br \/>\nli{<br \/>\nfloat:left;<br \/>\ndiv{margin:20px;}<br \/>\np{margin:20px;}<br \/>\n}<br \/>\n&amp;:hover{<br \/>\ncolor:red;\/\/&amp;\u53bb\u9664ul\u540e\u9762\u7684\u7a7a\u683c<br \/>\nfont:{<br \/>\nsize:10px;<br \/>\nweight:bold;<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>\u8fd0\u7b97\u3001\u5355\u4f4d\u3001\u8f6c\u4e49\u3001\u989c\u8272<br \/>\nwidth:@number*3;<br \/>\nheight:@number +20em;\/\/Sass\u4e0d\u652f\u6301\u5355\u4f4d\u4e0d\u540c\u8fdb\u884c\u6362\u7b97<br \/>\npadding:20px \/ 1.5;\/\/Less\u9664\u6cd5\u64cd\u4f5c\uff0cSass\u9ed8\u8ba4\u5206\u5272\u64cd\u4f5c<br \/>\npadding:~&#8221;20px \/ 1.5&#8243;;\/\/\u4e0d\u8fd0\u7b97padding:20px \/1.5<br \/>\npadding:(20px \/ 1.5);\/\/Sass\u505a\u9664\u6cd5\u8fd0\u7b97<br \/>\ncolor:#010203 *3;\/\/#030609<\/p>\n<p>\u51fd\u6570<br \/>\nwidth:round(3.5px);\/\/\u56db\u820d\u4e94\u5165<br \/>\nheight:percentage(0.2);\/\/\u767e\u5206\u6bd420%<br \/>\nrandom()\/\/\u53ea\u652f\u6301Sass<br \/>\nsqrt(25%)\/\/\u5f00\u65b9 \u53ea\u652f\u6301Less<br \/>\nfont-size:sum(4px,5px);<br \/>\n\u81ea\u5b9a\u4e49\u51fd\u6570<br \/>\n@function sum($n,$m){<br \/>\n@return $n+$m;<br \/>\n}<\/p>\n<p>\u6df7\u5165<br \/>\nLess:<br \/>\n.show{display:&#8217;block&#8217;;}<br \/>\n.show(@color){\/\/\u5982\u679c\u4e0d\u60f3\u7f16\u8bd1\u6b64\u6837\u5f0f\uff0c\u5728\u6837\u5f0f\u540d\u540e\u9762\u52a0()\u62ec\u53f7\uff0c\u62ec\u53f7\u91cc\u9762\u53ef\u4ee5\u5e26\u53c2\u6570<br \/>\ncolor:@color;<br \/>\n}<br \/>\n.box{<br \/>\nwidth:100px;<br \/>\n.show;<br \/>\n.show(blue);<br \/>\n}<\/p>\n<p>Sass:<br \/>\n@mixin show{<br \/>\ndisplay:&#8217;block&#8217;;<br \/>\n}<br \/>\n@mixin show($color){<br \/>\ndisplay:&#8217;block&#8217;;<br \/>\n}<br \/>\n.box{<br \/>\nwidth:100px;<br \/>\n@include show;<br \/>\n@include show(red);<br \/>\n}<\/p>\n<p>\u547d\u540d\u7a7a\u95f4Less<br \/>\n#nm(){<br \/>\n.show{display:inline-block;}<br \/>\n}<br \/>\n.box1{<br \/>\n#nm.show;<br \/>\n}<\/p>\n<p>\u7ee7\u627f<br \/>\nLess:<br \/>\n.line{display:inline;}<br \/>\n.box1{ &amp;:extend(.line);}<br \/>\n.box2{ &amp;:extend(.line);}<br \/>\n\u7f16\u8bd1\u540e<br \/>\n.line,<br \/>\n.box1,<br \/>\n.box2{<br \/>\ndisplay:inline;<br \/>\n}<\/p>\n<p>Sass:<br \/>\n%line{display:inline;}\/\/\u4e0d\u4f1a\u7f16\u8bd1\u51fa\u6765<br \/>\n.line{display:inline;}<br \/>\n.box1{@extend .line;}<br \/>\n.box2{@extend .line;}<br \/>\n\u7f16\u8bd1\u540e<br \/>\n.line,.box1,.box2{display:inline;}<\/p>\n<p>\u5408\u5e76<br \/>\nLess:<br \/>\n.box3{<br \/>\nbackground+ : url(1.png);\/\/+\u7b26\u53f7\u662f\u7528\uff0c\u9017\u53f7\u9694\u5f00<br \/>\nbackground+ : url(2.png);<br \/>\ntransform+_ :scale(2);\/\/+_ \u7b26\u53f7\u662f\u7528 \u7a7a\u683c \u9694\u5f00<br \/>\ntransform+_:rotate(30deg);<br \/>\n}<br \/>\n\u7f16\u8bd1\u540e\uff1a<br \/>\n.box3{<br \/>\nbackground:url(1.png),url(2.png);<br \/>\ntransform:scale(2) rotate(30deg)<br \/>\n}<\/p>\n<p>Sass:<br \/>\n$background:{<br \/>\na : url(1.png),<br \/>\nb: url(2.png)<br \/>\n}<br \/>\n$transform :{<br \/>\na:scale(2),<br \/>\nb:rotate(20deg)<br \/>\n}<br \/>\n.box3{<br \/>\nbackground:map-values($background);\/\/\u952e\u503c\u5bf9<br \/>\ntransform: zip(map-values($transform)&#8230;);\/\/\u628a\u9017\u53f7\u8f6c\u6210\u7a7a\u683c<br \/>\n}<\/p>\n<p>\u5a92\u4f53\u67e5\u8be2<br \/>\n.box2{<br \/>\nwidth:10px;<br \/>\n@media all and (min-width:768px){<br \/>\nwidth:600px;<br \/>\n}<br \/>\n@media all and (min-width:1440px){<br \/>\nwidth:900px;<br \/>\n}<br \/>\n}<\/p>\n<p>\u6761\u4ef6<br \/>\nLess:<br \/>\n@count:3;<br \/>\n.get(@cn) when ( @cn &gt;4){<br \/>\nwidth:100px + @cn;<br \/>\n}<br \/>\n.box{<br \/>\n.get(@count);<br \/>\n}<\/p>\n<p>Sass:<br \/>\n$count:3;<br \/>\n.box1{<br \/>\n@if($count&gt;4){<br \/>\nwidth: 100px + $count;<br \/>\n}<br \/>\n@else{<br \/>\nwidth: 10px + $count;<br \/>\n}<br \/>\n}<\/p>\n<p>\u5faa\u73af<br \/>\nLess:\u9012\u5f52\u5faa\u73af<br \/>\n@conut2 :0;<br \/>\n.get2(@cn) when (@cn &lt;3){<br \/>\n.get2((@cn+1));<br \/>\n.box-@{cn}{<br \/>\nwidth:100px +@cn;<br \/>\n}<br \/>\n}<br \/>\n.get2(@count2);<\/p>\n<p>Sass:\u652f\u6301for\u3001foreach<br \/>\n@for $i from 0 through 2{<br \/>\n.box-#{$i}{<br \/>\nwidth:100px + $i;<br \/>\n}<br \/>\n}<\/p>\n<p>\u5bfc\u5165<br \/>\nLess:<br \/>\n@import &#8216;\u6587\u4ef6\u8def\u5f84&#8217;;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sass\u548cLess Sass\u548cLess\u90fd\u5c5e\u4e8eCSS\u9884\u5904\u7406\u5668\uff0cCSS\u9884\u5904\u7406\u5668\u5b9a\u4e49\u4e86\u4e00\u79cd\u65b0\u7684\u8bed\u8a00\uff0c\u5176\u57fa\u672c\u601d\u60f3\u662f\uff0c\u7528 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-1611","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/1611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1611"}],"version-history":[{"count":4,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/1611\/revisions"}],"predecessor-version":[{"id":1800,"href":"https:\/\/www.9713job.com\/index.php?rest_route=\/wp\/v2\/posts\/1611\/revisions\/1800"}],"wp:attachment":[{"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.9713job.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}