Syntactically Awesome Stylesheet
Powerful professional grade CSS extension language in the world
Completely compatible with all version of CSS
Stable
Smaller than CSS
Easily to maintain
Not complex
Have Feature that not exist in CSS; variable, nesting, mixins, inheritance
Must save it out as a normal CSS file
Store information that you want to reuse throughout your stylesheet
SASS uses $ symbol to make something a variable
Store things; colors, font stacks or many CSS value that will reuse it
$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-color$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-colorbody {
font: 100% Helvetica, sans-serif;
color: #333;
}Nest CSS selectors that follows the same visual hierarchy of HTML
nav {
ul {
margin: 0;
padding: 0;
list-style: none;
}
li {
display: inline-block;
}
a {
display: block;
padding: 6px 12px;
text-decoration: none;
}
}nav ul {
margin: 0;
padding: 0;
list-style: none;
}
nav li {
display: inline-block;
}
nav a {
display: block;
padding: 6px 12px;
text-decoration: none;
}SASS uses & symbol to reference parent
Sometime useful to use a nested rule's parent selector
a {
color: #ce4dd6;
&:hover {
color: #ffb3ff;
}
&:visited {
color: #c458cb;
}
}
a {
color: #ce4dd6;
}
a:hover {
color: #ffb3ff;
}
a:visited {
color: #c458cb;
}
#main {
color: black;
&-sidebar {
border: 1px solid;
}
}#main {
color: black;
}
#main-sidebar {
border: 1px solid;
}Partial sass files that contains little code of css which can be included in other sass
Simply a SASS file named with a leading underscore
Underscore lets SASS know that the file is only a partial file and it should not be generated into a CSS file
Used with the @import directive
Import option that lets you split CSS into smaller, more maintainable portions
html,
body,
ul,
ol {
margin: 0;
padding: 0;
}
@import 'reset';
body {
font: 100% Helvetica, sans-serif;
background-color: #efefef;
}
@import 'reset';
body {
font: 100% Helvetica, sans-serif;
background-color: #efefef;
}
html, body, ul, ol {
margin: 0;
padding: 0;
}
body {
font: 100% Helvetica, sans-serif;
background-color: #efefef;
}
Mixins make group of CSS declaration that want to reuse
Make more flexible
Use @mixin directive and give it a name
Use @include followed by the name of the mixin
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.box {
@include border-radius(10px);
}
.box {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
}
.message {
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
@extend .message;
border-color: green;
}
.error {
@extend .message;
border-color: red;
}
.warning {
@extend .message;
border-color: yellow;
}
.message, .success, .error, .warning {
border: 1px solid #cccccc;
padding: 10px;
color: #333;
}
.success {
border-color: green;
}
.error {
border-color: red;
}
.warning {
border-color: yellow;
}
.container {
width: 100%;
}
article[role="main"] {
float: left;
width: 600px / 960px * 100%;
}
aside[role="complimentary"] {
float: right;
width: 300px / 960px * 100%;
}
.container {
width: 100%; }
article[role="main"] {
float: left;
width: 62.5%;
}
aside[role="complimentary"] {
float: right;
width: 31.25%;
}
*** take pixel values and convert them to percentages without much hassle
a.important {
@extend .notice
}a.important {
@extend .notice !optional;
}Normally when you extend a selector, it’s an error if @extend doesn’t work
Sometimes, though, you want to allow an @extend anyway. To do so, just add the !optional flag after the selector
http://alphapixels.com/prepros/