标签:
1.sass中可以使用变量
$company-blue: #1875e7; h1#brand { color: $company-blue; } #sidebar { background-color: $company-blue; }
ul.nav {float: right} ul.nav li {float: left;} ul.nav li a {color: #111} ul.nav li.current {font-weight: bold;}
ul.nav { float: right; li { float: left; a { color: #111; } &.current { font-weight: bold; } } }
#header ul.nav { float: right; } #header ul.nav li { float: left; margin-right: 10px; } #footer ul.nav { margin-top: 1em; } #footer ul.nav li { float: left; margin-right: 10px; }
@mixin horizontal-list { li { float: left; margin-right: 10px; } } #header ul.nav { @include horizontal-list; float: right; } #footer ul.nav { @include horizontal-list; margin-top: 1em; }
//混合器传参使用 @mixin horizontal-list($spacing: 10px) { //$spacing的默认值为10px,如果不传参则使用此值; li { float: left; margin-right: $spacing; } } #header ul.nav { @include horizontal-list; //使用$spacing默认值,即10px; float: right; } #footer ul.nav { @include horizontal-list(20px); //赋予$spacing新值为20; margin-top: 1em; }
//使用继承@extend,避免重复输出 .error { border: 1px #f00; background: #fdd; } .error.intrusion { font-size: 1.2em; font-weight: bold; } .badError { @extend .error; border-width: 3px; }
.error, .badError { border: 1px #f00; background: #fdd; } .error.intrusion, .badError.intrusion { font-size: 1.2em; font-weight: bold; } .badError { border-width: 3px; }
%button-reset { margin: 0; padding: .5em 1.2em; text-decoration: none; cursor: pointer; } .save { @extend %button-reset; color: white; background: #blue; } .delete { @extend %button-reset; color: white; background: red; }
.save, .delete { margin: 0; padding: .5em 1.2em; text-decoration: none; cursor: pointer; } .save { color: white; background: #blue; } .delete { color: white; background: red; }
标签:
原文地址:http://www.cnblogs.com/yugege/p/4839901.html