12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <!DOCTYPE html>
- <html lang="en-US">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width,initial-scale=1">
- <title>SASS Guide | 偶游前端</title>
- <meta name="generator" content="VuePress 1.9.7">
-
- <meta name="description" content="">
-
- <link rel="preload" href="/docs/assets/css/0.styles.e901f3ad.css" as="style"><link rel="preload" href="/docs/assets/js/app.9d841bbb.js" as="script"><link rel="preload" href="/docs/assets/js/2.a7c99d38.js" as="script"><link rel="preload" href="/docs/assets/js/24.b9b4a05b.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.dffec12e.js"><link rel="prefetch" href="/docs/assets/js/11.29345ef4.js"><link rel="prefetch" href="/docs/assets/js/12.d71ff1f2.js"><link rel="prefetch" href="/docs/assets/js/13.eadceca7.js"><link rel="prefetch" href="/docs/assets/js/14.86faea9b.js"><link rel="prefetch" href="/docs/assets/js/15.8cc4ecb6.js"><link rel="prefetch" href="/docs/assets/js/16.e10f6d69.js"><link rel="prefetch" href="/docs/assets/js/17.255d9f5b.js"><link rel="prefetch" href="/docs/assets/js/18.9f1823b8.js"><link rel="prefetch" href="/docs/assets/js/19.03db59c9.js"><link rel="prefetch" href="/docs/assets/js/20.f003980f.js"><link rel="prefetch" href="/docs/assets/js/21.5ec8f90e.js"><link rel="prefetch" href="/docs/assets/js/22.77e586e0.js"><link rel="prefetch" href="/docs/assets/js/23.793cee7f.js"><link rel="prefetch" href="/docs/assets/js/25.12ca9a6b.js"><link rel="prefetch" href="/docs/assets/js/3.de84d37d.js"><link rel="prefetch" href="/docs/assets/js/4.47824499.js"><link rel="prefetch" href="/docs/assets/js/5.bd819ce0.js"><link rel="prefetch" href="/docs/assets/js/6.dfb8683d.js"><link rel="prefetch" href="/docs/assets/js/7.0e5538c2.js"><link rel="prefetch" href="/docs/assets/js/8.d3104372.js"><link rel="prefetch" href="/docs/assets/js/9.f4b68565.js">
- <link rel="stylesheet" href="/docs/assets/css/0.styles.e901f3ad.css">
- </head>
- <body>
- <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/docs/" class="home-link router-link-active"><!----> <span class="site-name">偶游前端</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <!----></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><!----> <ul class="sidebar-links"><li><a href="/docs/" aria-current="page" class="sidebar-link">偶游前端(冯垣玮)</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>项目</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/docs/currentProgram/funfet.html" class="sidebar-link">智能鞋官网</a></li><li><a href="/docs/currentProgram/guide.html" class="sidebar-link">智能鞋落地页</a></li><li><a href="/docs/currentProgram/uni-app-pro.html" class="sidebar-link">智能鞋小程序商城</a></li><li><a href="/docs/currentProgram/customerService.html" class="sidebar-link">智能鞋客服系统</a></li><li><a href="/docs/currentProgram/tank.html" class="sidebar-link">坦克专题</a></li><li><a href="/docs/currentProgram/hiydMini.html" class="sidebar-link">hi运动教练小程序</a></li><li><a href="/docs/currentProgram/hiydShop.html" class="sidebar-link">hi运动商城</a></li><li><a href="/docs/currentProgram/webGame.html" class="sidebar-link">多玩游戏大厅</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="sass-guide"><a href="#sass-guide" class="header-anchor">#</a> SASS Guide</h1> <hr> <p>SASS规范指南,SASS 代码的基本规范和原则与 <a href="https://github.com/duowan/fe-guide/blob/master/css-guide.md" target="_blank" rel="noopener noreferrer">CSS 编码规范<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> 保持一致。</p> <hr> <h2 id="文档目录"><a href="#文档目录" class="header-anchor">#</a> 文档目录</h2> <ol><li><a href="#1-%E7%BC%96%E7%A0%81">编码</a></li> <li><a href="#2-%E4%BB%A3%E7%A0%81%E7%BB%84%E7%BB%87">代码组织</a></li> <li><a href="#3-import-%E8%AF%AD%E5%8F%A5"><code>@import</code> 语句</a></li> <li><a href="#4-%E5%8F%98%E9%87%8F">变量</a></li> <li><a href="#5-%E7%BB%A7%E6%89%BF">继承</a></li></ol> <h2 id="_1-编码"><a href="#_1-编码" class="header-anchor">#</a> 1 编码</h2> <p><strong>【强制】</strong> 使用UTF-8编码,每个SASS文件的第一行必须是定义编码的 <code>@charset "UTF-8";</code>;</p> <p>如果没定义编码,很有可能会出现跨平台兼容问题。</p> <h2 id="_2-代码组织"><a href="#_2-代码组织" class="header-anchor">#</a> 2 代码组织</h2> <p><strong>【强制】</strong> 代码必须按如下形式按顺序组织:</p> <ol><li>全局的变量声明 || <code>@import</code>;</li> <li>样式声明;</li></ol> <p>示例:</p> <div class="language-css extra-class"><pre class="language-css"><code>$<span class="token property">base-font-size</span> <span class="token punctuation">:</span> 12px !default<span class="token punctuation">;</span> // 字号
- $<span class="token property">base-font-family</span> <span class="token punctuation">:</span> <span class="token string">"Hiragino Sans GB"</span><span class="token punctuation">,</span> <span class="token string">"Microsoft Yahei"</span><span class="token punctuation">,</span> <span class="token string">"WenQuanYi Micro Hei"</span><span class="token punctuation">,</span> sans-serif !default<span class="token punctuation">;</span> // 字体族
- <span class="token atrule"><span class="token rule">@import</span> <span class="token string">"base/config"</span><span class="token punctuation">;</span></span>
- <span class="token atrule"><span class="token rule">@import</span> <span class="token string">"biz/page"</span><span class="token punctuation">;</span></span>
- <span class="token selector">body</span> <span class="token punctuation">{</span>
- <span class="token property">background</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
- <span class="token punctuation">}</span>
- </code></pre></div><h2 id="_3-import-语句"><a href="#_3-import-语句" class="header-anchor">#</a> 3 <code>@import</code> 语句</h2> <p><strong>【强制】</strong> 同一个SASS文件中的所有的 <code>@import</code>必须放在同一块,不允许分开:</p> <p><strong>【建议】</strong> 使用双引号引入SASS文件,至少同一项目要保持一致:</p> <h2 id="_4-变量"><a href="#_4-变量" class="header-anchor">#</a> 4 变量</h2> <p><strong>【强制】</strong> 变量命名必须采用 @foo-bar 形式,不允许使用 @fooBar 形式;</p> <p>示例:</p> <div class="language-css extra-class"><pre class="language-css"><code><span class="token comment">/* Not so great */</span>
- $<span class="token property">cardColor</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
- <span class="token comment">/* Better */</span>
- $<span class="token property">card-color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
- </code></pre></div><h2 id="_5-继承"><a href="#_5-继承" class="header-anchor">#</a> 5 继承</h2> <p><strong>【强制】</strong> 使用继承时,如果在声明块内书写 <code>@extend</code> 语句,必须写在开头;</p> <p>示例:</p> <div class="language-css extra-class"><pre class="language-css"><code><span class="token comment">/* Not so great */</span>
- <span class="token selector">.selector</span> <span class="token punctuation">{</span>
- <span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
- <span class="token atrule"><span class="token rule">@extend</span> sameStyle<span class="token punctuation">;</span></span>
- <span class="token punctuation">}</span>
- <span class="token comment">/* Better */</span>
- <span class="token selector">.selector</span> <span class="token punctuation">{</span>
- <span class="token atrule"><span class="token rule">@extend</span> sameStyle<span class="token punctuation">;</span></span>
- <span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
- <span class="token punctuation">}</span>
- </code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
- <script src="/docs/assets/js/app.9d841bbb.js" defer></script><script src="/docs/assets/js/2.a7c99d38.js" defer></script><script src="/docs/assets/js/24.b9b4a05b.js" defer></script>
- </body>
- </html>
|