css预处理器。其实还有用的不少的less,stylus。
SASS支持全部css语法
基础的文件命名方法以_开头css
SASS编译工具
?官方下载地址,下载对应版本html
用法:sass
demo.scssapp
$bg-color : #00a1e9; $bg-red : red; $nav-height : 50px; body{ background: $bg-color; } .demo{ height:$nav-height / 2; }
编译文件 demo.cssless
body { background: #00a1e9; } .demo { height: 25px; }
demo.scsskoa
a{ &:hover{ .demo{ background: $bg-red; } } }
编译文件 demo.css函数
a:hover .demo { background: red; }
demo.scss工具
.sub-title { color: #666; margin: 0; text-align: center; font-size: 32px; font-weight: bold; } p { @extend .sub-title; background: #fff; }
编译文件 demo.csscode
.sub-title, p { color: #666; margin: 0; text-align: center; font-size: 32px; font-weight: bold; } p { background: #fff; }
sass经过关键字 @mixin定义相似函数 格式:@mixin 函数名(){ }
经过@include 引入函数htm
封装函数能够写在一个单独的sass文件里,方便管理 //兼容ie opacity封装 @mixin opacity($opacity){ opacity: $opacity; filter: alpha(opacity=$opacity * 100); } //使用 .demo{ @include opacity(1); } ---------- //编译结果 .demo { opacity: 1; filter: alpha(opacity=100); }
好比:项目中有基础文件 _mixin.scss _header.scss _footer.scss 文件index.scss正好也须要引入这三个基础文件 @import "mixin"; @import "header"; @import "footer"; 引入基础的scss,不须要下划线和后缀名