文中sass的一些方法 來源於個人sassstd zhilizhili-mei zhilizhili-ui
npm 有出售 請你們自行拷貝粘貼
![]()
顏色要使用代詞加數字大小形式
數字規格 50 100 200 ... a100 ... b100
顏色變量不準由sass或者postcss方法計算得出css
$material-colors: ( 'red': ( '50': #ffebee, '100': #ffcdd2, '200': #ef9a9a, '300': #e57373, '400': #ef5350, '500': #f44336, '600': #e53935, '700': #d32f2f, '800': #c62828, '900': #b71c1c, 'a100': #ff8a80, 'a200': #ff5252, 'a400': #ff1744, 'a700': #d50000 ) )!global; // 項目顏色基於material design配色 基礎色庫設計師都會配出來 項目色庫須要項目去改變 $custom-color: map-extend($material-colors, ( "blue": ( "500": #0f8ffe, "600": #0088ff ), "red": ( "600": #f26c4f ), "green": ( "600": #d6e9ba ), "yellow": ( "600": #ecf82c ), "purple": ( "600": #e22cf8 ), "grey": ( "400": #c2c2c2, "500": #898989, "600": #464646 ) )) !global; @function get-custom-color($name, $level: "600") { @return map-deep-get($custom-color, $name, $level); }
設計師文字和前端頁面開發者文字必須爲同一類型
我以爲amazeui的文字設置就不錯
amaze ui 文字標準連接html
$font-family: ( "amazeui": ("Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans","wenquanyi micro hei","Hiragino Sans GB", "Hiragino Sans GB W3", Arial, sans-serif), "sans-serif": ("Segoe UI", "Lucida Grande", Helvetica, Arial, "Microsoft YaHei", FreeSans, Arimo, "Droid Sans","wenquanyi micro hei","Hiragino Sans GB", "Hiragino Sans GB W3", "FontAwesome", sans-serif), "serif": (Georgia, "Times New Roman", Times, SimSun, "FontAwesome", serif), //FangSong, STFangSong "monospace": (Monaco, Menlo, Consolas, "Courier New", "FontAwesome", monospace), "kai": (Georgia, "Times New Roman", Times, Kai, "Kaiti SC", KaiTi, BiauKai, "FontAwesome", serif) ) !global; @function get-font-family($name) { @return map-deep-get($font-family, $name); } @mixin interface-font() { .font { @content; } } @mixin use-font() { $defaults: ( ".font": ( ) ); @include interface-font() { @include register-hook("font"); @content; } } @mixin use-font-family($font-family-name, $sel) { #{$sel} { font-family: get-font-family($font-family-name); } } @mixin use-amazeui-font($sel: body) { @include use-font-family("amazeui", $sel); } @mixin use-sans-serif-font($sel: body) { @include use-font-family("sans-serif", $sel); } @mixin use-serif-font($sel: body) { @include use-font-family("serif", $sel); } @mixin use-monospace-font($sel: body) { @include use-font-family("monospace", $sel); } @mixin use-kai-font($sel: body) { @include use-font-family("kai", $sel); }
固然設計師有時會使用一些特殊字體 特別英文項目 很正常前端
@font-face { font-family: 'iconfont'; src: url('//at.alicdn.com/t/font_1450578408_6092355.eot'); /* IE9*/ src: url('//at.alicdn.com/t/font_1450578408_6092355.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('//at.alicdn.com/t/font_1450578408_6092355.woff') format('woff'), /* chrome、firefox */ url('//at.alicdn.com/t/font_1450578408_6092355.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/ url('//at.alicdn.com/t/font_1450578408_6092355.svg#iconfont') format('svg'); /* iOS 4.1- */ }
這個時個人iconfont引用 設計師若是想使用特殊字體 必須提供eot woff ttf svg各一份字體
不然前端有權不使用該字體html5
固然 我也要教你們 一些應對方案jquery
otf 轉爲 ttf 地址
ttf 轉爲 eotios
fontxchange 恩 這個軟件能夠作到轉換爲webfont 這個軟件mac有的 windows也有的 不過沒去找破解版 哈哈git
英文字體大小不是很大 能夠直接使用 中文字體因爲體積很大 因此須要優化
優化的方式就是 蒐集全部用到的字符 再根據蒐集到的字符從新生成一個新的字符文件github
font-spider 作的還不錯 可是有坑奧web
font-awesome 多是你們第一時間想到的 不過我想說的是iconfont或許更好chrome
icon 是小圖標 class .icon
icon 有多種提供形式 iconfont fontawesome unicode svg img
// example .icon.iconfont 代表她是iconfont 類型的icon
sass 或者 postcss 編寫 具體實現無論 可是必須保證變量不能夠由sass或postcss計算得出
$iconfont: ( "vars": ( "bule-tooth": "\e600", "moon": "\e601", "fastforward": "\e602", "plane": "\e603", "add": "\e604", "drag": "\e605", "more": "\e606", "rewind": "\e607", "search": "\e608", "star": "\e609", "world": "\e60a", "lock": "\e60b", "list": "\e60c", "volume-off": "\e60d", "share-arrow": "\e60e", "airplay": "\e60f", "close": "\e610", "glass": "\e611", "read": "\e612", "add-square": "\e613", "pause": "\e614", "wifi": "\e615", "user": "\e616", "back": "\e617", "close-circle": "\e618", "location": "\e619", "share": "\e61a", "volume-up": "\e61b", "right": "\e61c", "circle": "\e61d" ) ) !global; @function get-iconfont-var($name) { @return map-deep-get($iconfont, "vars", $name); } @mixin use-iconfont-iosicons() { $icons: map-deep-get($iconfont, "vars"); .iconfont { @each $iconname, $iconunicode in $icons { &.#{$fa-css-prefix}-#{$iconname}:before { content: $iconunicode; } } } }
項目中全部佈局 都由layout提供
組件也可使用layout 用來減小css代碼
// example <div class="btn-group"> <div class="layout flex horizontal align-items-center" role="group"> <div class="btn layout__item active">left</div> <div class="btn layout__item">center</div> <div class="btn layout__item">right</div> <div class="btn layout__item">right</div> </div> </div>
btn-group這個東西或許常見的是橫過來的 不過誰知道 他會不會被設計師設計成豎向的呢
layout 佈局要實現基本的有 table flex center-set(水平垂直居中實現)
不規定具體實現
以前我有說過ie8的問題 原本我是打算專門寫一篇文章的 不過算了吧 直接給你們帶來個人研究 以前ie8增強到ie9 polyfill 一文中已經解決一些問題 如今帶來一個完整模板
<!DOCTYPE html> <html class="no-js" lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title></title> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="/assets/static/css/normalize.css"> <script src="/assets/static/oldie/modernizr-2.8.3.min.js"></script> <!-- 總共35k 提供了dom3 es5 大部分功能 --> <!--[if IE 8]> <script src="./assets/static/oldie/es5-shim.min.js"></script> <script src="./assets/static/oldie/es5-sham.min.js"></script> <script src="./assets/static/oldie/ie8.min.js"></script> <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script> <script src="/assets/static/oldie/calc.min.js"></script> <![endif]--> <!-- dom4級 功能 --> <script src="../../public/js/modren-browser/dom4.min.js"></script </head> <body> <!--[if lt IE 8]> <div class="browsehappy"> <p> You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/" target="_blank">upgrade your browser</a> to improve your experience. </p> </div> <![endif]--> </body> </html>
jquery 部分你們自行選擇
<!--[if lt IE 9]> <script src="//cdn.bootcss.com/jquery/1.11.2/jquery.js"></script> <script>window.jQuery || document.write('<script src="/assets/static/oldie/jquery-1.11.2.min.js"><\/script>')</script> <![endif]--> <!--[if gt IE 8]><!--> <script src="//cdn.bootcss.com/jquery/2.1.3/jquery.js"></script> <script>window.jQuery || document.write('<script src="/assets/static/oldie/jquery-2.1.3.min.js"><\/script>')</script> <!--<![endif]-->
ie9也有一些問題 好比filereader之類的問題
webshim 給出了他的收集方案 連接
ie9進入grid佈局時代 chrome 已經原生支持 grid佈局 firefox也支持grid佈局 ie10開始支持grid佈局 使用polyfill咱們使ie9進入grid時代 連接