Tommy Gaessler
Developer Advocate at Zoom
Syntactically Awesome Stylesheets
Sassy CSS
(Sassy Cascading Stylesheets)
.next-slide {
color: #cf649a;
}$pink: #cf649a;
$green: #59CD90;
header {
background-color: $green;
}
h1 {
color: $pink;
}$pink: #cf649a
$green: #59CD90
header
background-color: $green
h1
color: $pink
SCSS
SASS
@mixin button-template($color) {
background-color: $color;
border: none;
border-radius: 5px;
padding: 15px;
color: white;
}
.button-one {
@include button-template($pink);
}
.button-two {
@include button-template($green);
}SCSS
.container {
margin: auto;
width: 80%;
max-width: 800px;
}
main {
@extend .container;
}SCSS
<main>
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Non ab nemo eligendi consequuntur, libero quae perspiciatis id, modi nisi rem saepe omnis nesciunt, in. Neque dolorum voluptas ad dolorem nostrum!</p>
</main>header {
position: relative;
padding: 15px;
@extend .container;
h3 {
display: inline;
font-size: 30px;
}
nav {
display: inline;
position: absolute;
right: 0;
a {
text-decoration: none;
color: $pink;
font-size: 25px;
margin-left: 15px;
}
}
}<header>
<h3>Logo</h3>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Contact</a>
</nav>
</header>SCSS
HTML
Result
$gutter: 2%;
.green {
height: 100vh;
width: (100% - ($gutter * 1)) / 2;
background-color: $green;
float: left;
}
.pink {
margin-left: $gutter;
height: 100vh;
width: (100% - ($gutter * 1)) / 2;
background-color: $pink;
float: left;
}SCSS
Result
header {
position: relative;
padding: 15px;
@extend .container;
h3 {
display: inline;
font-size: 30px;
}
nav {
display: inline;
position: absolute;
right: 0;
a {
text-decoration: none;
color: $pink;
font-size: 25px;
margin-left: 15px;
}
}
}@import 'header';
@import 'home';
@import 'footer';_header.sccs
styles.scss
SASS FACT:
There are if else statements in SASS
@import 'header';
@import 'home';
@import 'footer';styles.scss
.container, header {
margin: auto;
width: 80%;
max-width: 800px;
}
header {
position: relative;
padding: 15px;
}
header h3 {
display: inline;
font-size: 30px;
}
header nav {
display: inline;
position: absolute;
right: 0;
}
header nav a {
text-decoration: none;
color: #cf649a;
font-size: 25px;
margin-left: 15px;
}
styles.css
SASS FACT:
There are for, for each, and while loops in SASS
$ npm install node-sass$ sass input.scss output.css$ sass --watch input.scss:output.cssor
or
$ sass --watch src/sass:src/cssBy Tommy Gaessler
SASS