@charset "UTF-8";
$value: #000 5px 10px 15px 20px 1;
.element {
border: {
style: solid;
color: nth($value,1);
width: auto;
}
border-radius: nth($value,3);
margin: nth($value,2) nth($value,3);
padding: nth($value,3) nth($value,5);
line-height: nth($value,6);
}
$map: (
"font-family": "Comic Sans MS',Arial,'Microsoft Yahei",
"font-size": 12px,
"color": #000,
"background-color": black
);
h1 {
font-family: map-get($map,"font-family");
font-size: map-get($map,"font-size");
}
.aboutSection {
padding: 5px;
border: {
style: solid;
color: #000;
width: 1px;
}
&-abc {
display: block;
}
&_abc {
display: inline;
}
&:hover {
color: #ff0000;
}
&:before {
content: "Sass嵌套";
}
article {
h1 {
color: #333;
}
> p {
margin-bottom: 1.4em;
}
}
}
$width: 10em;
#main {
$height: 5em !global;
width: $width;
height: $height;
}
#sidebar {
height: $height;
}
@mixin font {
font-family: "宋体";
font-size: 14px;
color: #333;
a {
display: inline-block;
margin-left: 10px;
margin-right: 10px;
}
&:hover {
color: #007aff;
}
}
nav {
display: block;
@include font;
}
@mixin test {
p {
color: #f00;
}
}
@include test;
@mixin linkColor($normal,$hover,$active) {
color: $normal;
&:hover { color: $hover; }
&:active { color: $active; }
}
a{
@include linkColor(red,green,blue);
}
input {
@include linkColor(
$hover: #0f0,
$normal: #f00,
$active: #00f
);
}
@mixin borderRadius(
$borderTopLeft: 10px,
$borderTopRight: $borderTopLeft,
$borderBottomLeft: $borderTopLeft,
$borderBottomRight: $borderTopLeft
){
border-top-left-radius: $borderTopLeft;
border-top-right-radius: $borderTopRight;
border-bottom-left-radius: $borderBottomLeft;
border-bottom-right-radius: $borderBottomRight;
}
button{ @include borderRadius; }
button{ @include borderRadius(2px); }
button{ @include borderRadius(null); }
button{ @include borderRadius(2px,5px,null); }
button{ @include borderRadius(2px,5px); }
button{ @include borderRadius(2px,$borderBottomRight: 0); }
button{ @include borderRadius($borderBottomRight: 0); }
button{ @include borderRadius($borderBottomRight: null); }
button{ @include borderRadius(null,$borderBottomRight: 10px); }
button{ @include borderRadius($borderTopRight: 0,$borderBottomLeft: 0); }
@mixin borderRadius2(
$borderTopLeft: 1px,
$borderTopRight: 2px,
$borderBottomLeft: 3px,
$borderBottomRight: 5px
){
border-top-left-radius: $borderTopLeft;
border-top-right-radius: $borderTopRight;
border-bottom-left-radius: $borderBottomLeft;
border-bottom-right-radius: $borderBottomRight;
}
div{ @include borderRadius2; }
div{ @include borderRadius2(0,5px); }
div{ @include borderRadius2($borderBottomRight: 4px); }
div{ @include borderRadius2($borderTopRight: 0,$borderBottomRight: 0); }
$color: white;
@mixin colors($color: blue) {
background-color: $color;
@content;
border-color: $color;
}
.colors {
@include colors(red) { color: $color; }
}
.colors {
@include colors;
}
aside {
font-size: 20px;
@extend .error;
}
.error {
border: 1px solid #000;
background-color: #f1f1f1;
}
.error p {
display: block;
text-align: center;
}
p .error {
border-color: yellow;
text-decoration: underline;
}
.parent.error {
border-color: yellow;
text-decoration: underline;
}
nav.error {
border-color: yellow;
text-decoration: underline;
}
$a_bc: 12px;
a{
font-size: $a-bc;
}
@mixin _abc {
a { background-color: #eee; }
}
@include -abc;
%btn {
padding: 5px 10px;
font-size: 12px;
color: #333;
background-color: #e6e6e6;
border-radius: 3px;
border: 1px solid #adadad;
}
.confirm-btn {
@extend %btn;
color: #fff;
background-color: #428bca;
border-color: #357ebd;
}
.error-btn {
@extend %btn;
color: #fff;
background-color: #d9534f;
border-color: #d43f3a;
}
$version: "1.2.3";
$sideBarWidth: 200px;
#main {
width: calc(100% - #{$sideBarWidth});
}
@mixin selector($selector:left,$attribute:margin)
{
.main-#{$selector} {
max-width: 100%;
min-height: 100%;
#{$attribute}-left: auto;
#{$attribute}-right: auto;
}
.main-#{$selector}:after {
content: "#{5+10}";
}
}
@include selector(right);
#test {
padding: 10px-5px;
font: 10px/8px;
$value: 100px;
width: $value/2;
width: round(1.5)/2;
height: (20px/2);
margin-left: 100px + 8px/2px;
$size: 18px;
line-height: $size/1px;
}
#test:after {
}
p {
color: #010203*0;
background-color: #333 + #666;
color: rgba(255, 0, 0, 0.75) + rgba(0, 255, 0, 0.75);
}
body {
@media screen and (orientation: landspace){
background-color: #fff;
* {
color: #fff;
}
}
}
$media: screen;
$feature: -webkit-min-device-pixel-ratio;
$value: 1.5;
@media #{$media} and ($feature:$value) {
.sidebar {
width: 500px;
}
}
@function run($a,$b) {
@return $a*$b+px
}
.run {
font-size: run(2,10);
}
p {
@if 1 + 1 == 2 { border: 1px solid #eee; }
@if not (5 > 3) { border: 2px dotted #333; }
@if null { border: 3px double #666; }
}
$type: inline-block;
p {
@if $type == block {
display: block;
} @else if $type == inline {
display: inline;
} @else if $type == inline-block {
display: inline-block;
} @else {
display: none;
}
}
@for $fz from 12 through 16 {
.fz-#{$fz} {
font-size: #{$fz}px;
}
}
@for $fz from 12 to 16 {
.fz-#{$fz} {
font-size: #{$fz}px;
}
}
@each $fontSize in 12px, 14px, 16px {
.fz-#{$fontSize} {
font-size: $fontSize;
}
}
$i: 6;
@while $i <= 8 {
.item-#{$i*2} { width: 2px * $i; }
$i: $i + 1;
}
console