sass技术是Syntactically Awesome Stylesheete Sass的缩写,Sass能够简化你的Css工做流,并可使你的Css的扩展和维护工做变的更加容易。css
1.sass有两种后缀名.sass和.scss通常习惯于使用.scsshtml
//文件后缀名为sass的语法 body background: #eee font-size:api
12px p background: #0982c1 sass
//文件后缀名为scss的语法 body { background: #eee; font-size:12px; }ide
p{ background: #0982c1; } 模块化
scss变量:$变量名函数
eg:$color:blue;ui
p{color:$color;}spa
!default:在模块化中,运用别人的模块scss,就可使用$color:blue !default;orm
特殊变量:#$变量名
eg: $direct:top;
.border-#$direct{border-top:1px solid red;}
编译后css: border-top{border-top:1px solid red;}
多值变量:经过nth($变量名,第几个)函数取值
$num:1px 2px 3px 2px;
div{padding:$num; margin,:nth($num,键);
$map:(a1:10em,a2:15em,a3:20em);
body{width:map_get($map,a1);}
选择器嵌套
#top_nav{ line-height: 40px;
text-transform: capitalize;
background-color:#333;
li{ float:left; }
a{ display: block; padding: 0 10px; color: #fff;
&:hover{ color:#ddd; } } }
属性嵌套:
.fakeshadow {
border: { style: solid;
left: { width: 4px; color: #888; }
right: { width: 2px; color: #ccc; } } }
*参考资料http://www.w3cplus.com/sassguide/syntax.html*