Sass與Web組件化相關的功能

來源:互聯網
上載者:User

標籤:容器   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組件化相關的功能

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.