{"id":52545,"date":"2024-12-03T09:12:04","date_gmt":"2024-12-03T01:12:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52545\/"},"modified":"2024-12-03T09:12:04","modified_gmt":"2024-12-03T01:12:04","slug":"scss-%e4%b8%ad%e5%a6%82%e4%bd%95%e7%9b%b4%e6%8e%a5%e8%ae%bf%e9%97%ae%e5%8f%98%e9%87%8f%e7%bb%84%e4%b8%ad%e7%9a%84%e7%89%b9%e5%ae%9a%e5%80%bc%ef%bc%9f-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52545\/","title":{"rendered":"SCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>SCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f<\/h1>\n<p>\u54c8\u55bd\uff01\u5927\u5bb6\u597d\uff0c\u5f88\u9ad8\u5174\u53c8\u89c1\u9762\u4e86\uff0c\u6211\u662f\u7c73\u4e91\u7684\u4e00\u540d\u4f5c\u8005\uff0c\u4eca\u5929\u7531\u6211\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aSCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f\u300b<\/span>\uff0c\u672c\u6587\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60\u8fdb\u6b65\uff0c\u4e5f\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u3001\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u8f6c\u53d1! \u4e0b\u9762\u5c31\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241121\/1732171379673ed6735b4c3.jpg\" class=\"aligncenter\" title=\"SCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f\u63d2\u56fe\" alt=\"SCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 scss \u4e2d\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u503c<\/strong><\/p>\n<p>\u5728 scss \u4e2d\u5b9a\u4e49\u53d8\u91cf\u7ec4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 $spacer \u8fd9\u6837\u7684\u53d8\u91cf\u540d\u6765\u8bbf\u95ee\u6574\u4e2a\u7ec4\u3002\u4f46\u662f\uff0c\u5982\u679c\u9700\u8981\u5728\u6837\u5f0f\u8868\u4e2d\u76f4\u63a5\u8bbf\u95ee\u7ec4\u4e2d\u7279\u5b9a\u503c\uff0c\u8be5\u600e\u4e48\u505a\u5462\uff1f<\/p>\n<p>\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 @each \u5faa\u73af\u904d\u5386\u7ec4\u4e2d\u7684\u503c\uff0c\u7136\u540e\u751f\u6210\u5305\u542b\u8be5\u503c\u7684\u5b9e\u9645\u7c7b\uff1a<\/p>\n<pre>$spacer: (\n  sm: 5px,\n  base: 10px,\n  lg: 15px,\n);\n\n@each $key, $value in $spacer {\n  .sp-#{$key} {\n    margin-top: $value;\n  }\n}<\/pre>\n<p>\u4f46\u662f\uff0c\u662f\u5426\u6709\u66f4\u7b80\u6d01\u7684\u65b9\u6cd5\u76f4\u63a5\u8bbf\u95ee\u7ec4\u4e2d\u7279\u5b9a\u503c\uff1f<\/p>\n<p>\u662f\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528 sass \u7684 map-get() \u51fd\u6570\uff1a<\/p>\n<pre>.MyClass {\n  margin-top: map-get($spacer, 'sm');\n}<\/pre>\n<p>\u8fd9\u6837\u5c31\u53ef\u4ee5\u76f4\u63a5\u5728 $spacer \u53d8\u91cf\u7ec4\u4e2d\u8bbf\u95ee &#8216;sm&#8217; \u952e\u7684\u503c\uff0c\u8fd9\u662f 5px\u3002<\/p>\n<p>\u4eca\u5929\u5173\u4e8e\u300aSCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f\u300b\u7684\u5185\u5bb9\u5c31\u4ecb\u7ecd\u5230\u8fd9\u91cc\u4e86\uff0c\u662f\u4e0d\u662f\u5b66\u8d77\u6765\u4e00\u76ee\u4e86\u7136\uff01\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u5185\u5bb9\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5149\u5f71\u7cbe\u7075\u7b14\u8bb0\u672c\u600e\u4e48\u91cd\u88c5Win11\u7cfb\u7edf \u5149\u5f71\u7cbe\u7075\u7b14\u8bb0\u672c\u91cd\u88c5Win11\u7684\u6559\u7a0b\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>SCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f \u54c8\u55bd\uff01\u5927\u5bb6\u597d\uff0c\u5f88\u9ad8\u5174\u53c8\u89c1\u9762\u4e86\uff0c\u6211\u662f\u7c73\u4e91\u7684\u4e00\u540d\u4f5c\u8005\uff0c\u4eca\u5929\u7531\u6211\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u7bc7\u300aSCSS \u4e2d\u5982\u4f55\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u7279\u5b9a\u503c\uff1f\u300b\uff0c\u672c\u6587\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5e0c\u671b\u5927\u5bb6\u4e00\u8d77\u5b66\u4e60\u8fdb\u6b65\uff0c\u4e5f\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u3001\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u8f6c\u53d1! \u4e0b\u9762\u5c31\u4e00\u8d77\u6765\u770b\u770b\u5427\uff01 \u5982\u4f55\u5728 scss \u4e2d\u76f4\u63a5\u8bbf\u95ee\u53d8\u91cf\u7ec4\u4e2d\u7684\u503c \u5728 scss \u4e2d\u5b9a\u4e49\u53d8\u91cf\u7ec4\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528 $spacer \u8fd9\u6837\u7684\u53d8\u91cf\u540d\u6765\u8bbf\u95ee\u6574\u4e2a\u7ec4\u3002\u4f46\u662f\uff0c\u5982\u679c\u9700\u8981\u5728\u6837\u5f0f\u8868\u4e2d\u76f4\u63a5\u8bbf\u95ee\u7ec4\u4e2d\u7279\u5b9a\u503c\uff0c\u8be5\u600e\u4e48\u505a\u5462\uff1f \u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528 @each \u5faa\u73af\u904d\u5386\u7ec4\u4e2d\u7684\u503c\uff0c\u7136\u540e\u751f\u6210\u5305\u542b\u8be5\u503c\u7684\u5b9e\u9645\u7c7b\uff1a $spacer: ( sm: 5px, base: 10px, lg: 15px, ); @each $key, $value in $spacer { .sp-#{$key} { margin-top: $value; } } \u4f46\u662f\uff0c\u662f\u5426\u6709\u66f4\u7b80\u6d01\u7684\u65b9\u6cd5\u76f4\u63a5\u8bbf\u95ee\u7ec4\u4e2d\u7279\u5b9a\u503c\uff1f \u662f\u7684\uff0c\u53ef\u4ee5\u4f7f\u7528 sass \u7684 map-get() \u51fd\u6570\uff1a .MyClass { margin-top: map-get($spacer, &#8216;sm&#8217;); } \u8fd9\u6837\u5c31\u53ef\u4ee5\u76f4\u63a5\u5728 $spacer \u53d8\u91cf\u7ec4\u4e2d\u8bbf\u95ee &#8216;sm&#8217; \u952e\u7684\u503c\uff0c\u8fd9\u662f 5px\u3002 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-52545","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52545"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52545\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}