Sass basic common guide and sass Guide

Source: Internet
Author: User

Sass basic common guide and sass Guide

I. Variables

$global-color:red;.nav{  background:$global-color;  }

II. the horizontal bars and underscores are not distinguished during sass naming.

$global-color:yellow;.nav{  background-color:$global_color  }.footer{  background-color:$global-color}

3. variables can be applied

$global-color:red;$global-border:1px solid $global-color;.nav{  backhround:$global-color; border:$global-border;    }


Iv. nesting rules

#head{  .nav{    background:red;     .logo{      float:left;    }  }  p{    color:red   }}

V. Pseudo-classes and direct calling of parent-level symbols &

#head{  a{    color:biue;    &:hover{      color:red    }        }}


Vi. sass Import

@import "header";.main{  color:red;}@import "fotter";

VII. nested Import

@import "header";.main{  color:red;  @import "main";}@import "fotter";

8. Comments

The following comments will be compiled/** time: * auther: liumingwang **/The following comments will not be compiled // color silent comments

9. Default Variables

@ Import "header"; $ color: red! Default; // here is the default variable. If there is a variable in "header", it is used in the header. If there is no variable in the header, the default variable on this page is used. head {color: $ color ;}

10. mixin for Mixer

@mixin border-radius{ -moz-border-radius:5px; -webkit-border-radius:5px; -o-border-radius:5px; -ms-border-radius:5px; border-radius:5px;}.header{  &-nav{    @include border-radius;  }}

11. mixin parameters of the mixer

@mixin links-color($nomal,$hover,$visited,$active){  color:$nomal;  &:hover{   color:$hover;  }  &:visited{    color:$visited  }  &:active{    color:$active  }}.header{  @include links-color(red,blue,green,yellow)}


12. Inheritance

.center{  margin:0 auto;}.main{  @extend .center}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.