標籤:容器 html version direct class opera list guid generated
Sass
https://en.wikipedia.org/wiki/Sass_(stylesheet_language)
Sass (Syntactically Awesome Stylesheets) is a style sheet language initially designed by Hampton Catlin and developed by Natalie Weizenbaum.[2][3] After its initial versions, Weizenbaum and Chris Eppstein continu
官網
http://sass-lang.com
Sass is the most mature, stable, and powerful professional grade CSS extension language in the world.
認識:
實際上Sass規定了一套CSS文法, 此文法不是在瀏覽器上執行的, 而是為了編寫css檔案便利, 以及維護便利, 由Sass工具在編譯環境中,將sass檔案轉換為css檔案, 此檔案可以在瀏覽器上跑。
http://sass-lang.com/guide
git
https://github.com/sass/sass
安裝:
http://sass-lang.com/install
http://www.ruanyifeng.com/blog/2012/06/sass.html
功能
http://sass-lang.com/guide
Variables
$font-stack: Helvetica, sans-serif;$primary-color: #333;body { font: 100% $font-stack; color: $primary-color;}
Nesting
不過太深的嵌套, 也不利於維護, 不建議使用。
nav { ul { margin: 0; padding: 0; list-style: none; } li { display: inline-block; } a { display: block; padding: 6px 12px; text-decoration: none; }}
Partials
The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the @import directive.
_partial.scss
Import
// _reset.scsshtml,body,ul,ol { margin: 0; padding: 0;}
// base.scss@import ‘reset‘;body { font: 100% Helvetica, sans-serif; background-color: #efefef;}
Mixins
@mixin border-radius($radius) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius;}.box { @include border-radius(10px); }
Extend/Inheritance
.message { border: 1px solid #ccc; padding: 10px; color: #333;}.success { @extend .message; border-color: green;}
Operators
.container { width: 100%; }article[role="main"] { float: left; width: 600px / 960px * 100%;}
組件化相關
組件化牽扯到如下功能:
1、 Partials, 保證每個組件的css檔案可以獨自管理。
2、 Extends/Inheritance, 繼承 可以保證相同組件, 繼承同一個父親樣式。
3、 Mixins, 可以讓相同功能的一套代碼, 以函數的方式, 定義在一起。
4、 Imports, 保證容器控制項, 可以組合容器中子控制項的樣式。
Sass與Web組件化相關的功能