$ 的使用
|
渲染效果
|
$primary-color: #333;
body {
color: $primary-color;
}
|
body {
color: #333; }
|
& 的使用,使用当前容器名称
|
|
a {
font-weight: bold;
&:hover { text-decoration: underline; }
body.firefox & { font-weight: normal; }
}
|
a {
font-weight: bold; }
a:hover {
text-decoration: underline; }
body.firefox a {
font-weight: normal; }
#main-sidebar {
border: 1px solid; }
|
嵌套使用 |
|
nav {
ul {
margin: 0;
padding: 0;
list-style: none;
}
li { display: inline-block; }
}
|
nav ul {
margin: 0;
padding: 0;
list-style: none; }
nav li {
display: inline-block; }
|
导入scss文件 |
渲染后会合并 |
|
html, body, ul, ol {
margin: 0;}
body {
font: 100% Helvetica, sans-serif; }
|
@mixin 和
@include |
|
@mixin border-radius($radius) {
border-radius: $radius;
-ms-border-radius: $radius;
}
.box {
@include border-radius(10px);
}
|
.box {
border-radius: 10px;
-ms-border-radius: 10px; }
|
@extend 继承 |
|
%message-common {
padding: 10px;
color: #333;
}
.message {
@extend %message-common;
}
.success { @extend %message-common; border-color: green; }
|
.message, .success {
padding: 10px;
color: #333; }
.success {
border-color: green; }
|
|
|
div[role="main"] {
width: 600px / 960px * 100%;
}
|
div[role="main"] {
width: 62.5%; }
|
嵌套属性 |
|
.demo {
|
.demo {
font-family: fantasy;
font-size: 30em; }
|
嵌套属性2 |
|
.demo {
font: 20px/24px fantasy {
weight: bold;
}
}
|
.demo {
font: 20px/24px fantasy;
font-weight: bold;
}
|