sass-guide.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html lang="en-US">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width,initial-scale=1">
  6. <title>SASS Guide | 偶游前端</title>
  7. <meta name="generator" content="VuePress 1.5.0">
  8. <meta name="description" content="">
  9. <link rel="preload" href="/docs/assets/css/0.styles.fa04140f.css" as="style"><link rel="preload" href="/docs/assets/js/app.6eb096df.js" as="script"><link rel="preload" href="/docs/assets/js/2.eb3dc6dc.js" as="script"><link rel="preload" href="/docs/assets/js/18.bac57b7c.js" as="script"><link rel="prefetch" href="/docs/assets/js/10.121c4396.js"><link rel="prefetch" href="/docs/assets/js/11.4152d57d.js"><link rel="prefetch" href="/docs/assets/js/12.6f3f98e4.js"><link rel="prefetch" href="/docs/assets/js/13.121cf2d2.js"><link rel="prefetch" href="/docs/assets/js/14.15bdf673.js"><link rel="prefetch" href="/docs/assets/js/15.5a659b8b.js"><link rel="prefetch" href="/docs/assets/js/16.6c83c4bd.js"><link rel="prefetch" href="/docs/assets/js/17.a200da04.js"><link rel="prefetch" href="/docs/assets/js/19.6246c10b.js"><link rel="prefetch" href="/docs/assets/js/3.34e7d28d.js"><link rel="prefetch" href="/docs/assets/js/4.c124f7a5.js"><link rel="prefetch" href="/docs/assets/js/5.36672b5d.js"><link rel="prefetch" href="/docs/assets/js/6.2072c2b2.js"><link rel="prefetch" href="/docs/assets/js/7.c034f81f.js"><link rel="prefetch" href="/docs/assets/js/8.8ed5f3ae.js"><link rel="prefetch" href="/docs/assets/js/9.39b37f48.js">
  10. <link rel="stylesheet" href="/docs/assets/css/0.styles.fa04140f.css">
  11. </head>
  12. <body>
  13. <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/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><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/standard/html-guide.html" class="sidebar-link">HTML规范</a></li><li><a href="/docs/standard/css-guide.html" class="sidebar-link">css规范</a></li><li><a href="/docs/standard/javascript-guide.html" class="sidebar-link">JavaScript规范</a></li><li><a href="/docs/standard/directory-guide.html" class="sidebar-link">目录规范</a></li></ul></section></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/utils/fetch.html" class="sidebar-link">Fetch</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>博客</span> <!----></p> <!----></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 编码规范<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" 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></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 &quot;UTF-8&quot;;</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> // 字号
  14. $<span class="token property">base-font-family</span> <span class="token punctuation">:</span> <span class="token string">&quot;Hiragino Sans GB&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;Microsoft Yahei&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;WenQuanYi Micro Hei&quot;</span><span class="token punctuation">,</span> sans-serif !default<span class="token punctuation">;</span> // 字体族
  15. <span class="token atrule"><span class="token rule">@import</span> <span class="token string">&quot;base/config&quot;</span><span class="token punctuation">;</span></span>
  16. <span class="token atrule"><span class="token rule">@import</span> <span class="token string">&quot;biz/page&quot;</span><span class="token punctuation">;</span></span>
  17. <span class="token selector">body</span> <span class="token punctuation">{</span>
  18. <span class="token property">background</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
  19. <span class="token punctuation">}</span>
  20. </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>
  21. $<span class="token property">cardColor</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
  22. <span class="token comment">/* Better */</span>
  23. $<span class="token property">card-color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
  24. </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>
  25. <span class="token selector">.selector</span> <span class="token punctuation">{</span>
  26. <span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
  27. <span class="token atrule"><span class="token rule">@extend</span> sameStyle<span class="token punctuation">;</span></span>
  28. <span class="token punctuation">}</span>
  29. <span class="token comment">/* Better */</span>
  30. <span class="token selector">.selector</span> <span class="token punctuation">{</span>
  31. <span class="token atrule"><span class="token rule">@extend</span> sameStyle<span class="token punctuation">;</span></span>
  32. <span class="token property">color</span><span class="token punctuation">:</span> #fff<span class="token punctuation">;</span>
  33. <span class="token punctuation">}</span>
  34. </code></pre></div></div> <footer class="page-edit"><!----> <!----></footer> <!----> </main></div><div class="global-ui"></div></div>
  35. <script src="/docs/assets/js/app.6eb096df.js" defer></script><script src="/docs/assets/js/2.eb3dc6dc.js" defer></script><script src="/docs/assets/js/18.bac57b7c.js" defer></script>
  36. </body>
  37. </html>