SlideShare uma empresa Scribd logo
1 de 20
Sass
( Syntactically Awesome Style Sheets )
Scss
(SCSS is called Sassy CSS)
( Sassy Cascading Style Sheets)
// Sass
$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-color
// Scss
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
Final Output css
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
Syntax
#plain-text {
content: "I'm 1 + 2 years old";
}
#interpolated {
content: "I'm #{1 + 3} years old";
}
1 + 1 //2 (addition)
1 - 1 //0 (subtraction)
2 * 3 //6 (multiplication)
(6 / 3) //2 (division, see below for an explanation of the parentheses)
5 % 2 //5 (modulus)
Final Output
#plain-text {
content: "I'm 1 + 2 years old";
}
#interpolated {
content: "I'm 4 years old";
}
Scss – Basic Arithmetic
$width: 800px;
.container-1 {
width: $width;
}
.column-2 {
width: $width / 2;
}
.column-3 {
width: $width / 5;
}
Final Output
.container-1 {
width: 800px;
}
.column-2 {
width: 400px;
}
.column-3 {
width: 160px;
}
Scss – Basic Arithmetic
#plain-text {
content: "I'm 1 + 2 years old";
}
#interpolated {
content: "I'm #{1 + 3} years old";
}
5 < 3 //false (less than)
5 > 3 //true (greater than)
3 <= 3 //true (less than or equal to)
5 >= 3 //true (greater than or equal to)
Final Output
#plain-text {
content: "I'm 1 + 2 years old";
}
#interpolated {
content: "I'm 4 years old";
}
Scss – Comparison Operators
$title-font: normal 24px/1.5 'Open Sans', sans-serif;
$cool-red: #F44336;
$box-shadow-bottom-only: 0 2px 1px 0 rgba(0, 0, 0, 0.2);
h1.title {
font: $title-font;
color: $cool-red;
}
div.container {
color: $cool-red;
background: #fff;
width: 100%;
box-shadow: $box-shadow-bottom-only;
}
Final Output
h1.title {
font: normal 24px/1.5 "Open Sans", sans-serif;
color: #F44336;
}
div.container {
color: #F44336;
background: #fff;
width: 100%;
box-shadow: 0 2px 1px 0 rgba(0, 0, 0, 0.2);
}
Scss - Variables
Sass @-Rules and Directives
@import
@media
@extend
@include
@Import
// _reset.scss
html,
body,
ul,
ol {
margin: 0;
padding: 0;
}
// base.scss
@import 'reset';
body {
font: 100% Helvetica, sans-serif;
background-color: #efefef;
}
Final Output
html, body, ul, ol {
margin: 0;
padding: 0;
}
body {
font: 100% Helvetica, sans-serif;
background-color: #efefef;
}
@Media
$size: 100px;
.box {
width:$size;
@media (min-width: 800px) {
width:$size + 50;
@media (max-width: 1200px) {
width:$size * 2;
}
}
}
Final Output
.box {
width: 100px;
}
@media (min-width: 800px) {
.box {
width: 150px;
}
}
@media (min-width: 800px) and (max-width: 1200px) {
.box {
width: 200px;
}
}
@Nesting
ul {
list-style: none;
li {
padding: 15px;
display: inline-block;
a {
text-decoration: none;
font-size: 16px;
color: #444;
}
}
}
Final Output
ul {
list-style: none;
}
ul li {
padding: 15px;
display: inline-block;
}
ul li a {
text-decoration: none;
font-size: 16px;
color: #444;
}
@Extend
.dialog-button {
box-sizing: border-box;
color: #ffffff;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
padding: 12px 40px;
cursor: pointer;
}
.confirm {
@extend .dialog-button;
background-color: #87bae1;
float: left;
}
.cancel {
@extend .dialog-button;
background-color: #e4749e;
float: right;
}
Final Output
.dialog-button, .confirm, .cancel {
box-sizing: border-box;
color: #fff;
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12);
padding: 12px 40px;
cursor: pointer;
}
.confirm {
background-color: #87bae1;
float: left;
}
.cancel {
background-color: #e4749e;
float: right;
}
@for
@for $i from 1 to 5 {
.padding-#{$i} {
padding: $i;
}
}
Final Output
.padding-1 {
padding: 1;
}
.padding-2 {
padding: 2;
}
.padding-3 {
padding: 3;
}
.padding-4 {
padding: 4;
}
@for $i from 1 through 5 {
.padding-#{$i}{ padding: $i;}
}
Final Output
.padding-1 {
padding: 1;
}
.padding-2 {
padding: 2;
}
.padding-3 {
padding: 3;
}
.padding-4 {
padding: 4;
}
.padding-5 {
padding: 5;
}
@for
$color: "blue", "green", "orange", "red",
"pink", "grey", "black";
@for $i from 1 through length($color){
.color-#{ nth($color, $i) }
{
color: #{ nth($color, $i)
}
}
}
Final Output
.color-blue {
color: blue;
}
.color-green {
color: green;
}
.color-orange {
color: orange;
}
.color-red {
color: red;
}
.color-pink {
color: pink;
}
.color-grey {
color: grey;
}
@while
$i: 1;
@while $i <= 5 {
wd-#{$i}{
width: #{$i};
}
$i: $i + 1;
}
Final Output
wd-1 {
width: 1;
}
wd-2 {
width: 2;
}
wd-3 {
width: 3;
}
wd-4 {
width: 4;
}
wd-5 {
width: 5;
}
@Each
$colour: (
red: #00ff00,
green: #ff0000,
blue: #0000ff,
lightgreen: #ff00ff,
lightblue: #ffff00);
@each $labelname, $colouritem in $colour {
.#{$labelname} {
color: $colouritem;
}
}
Final Output
.red {
color: #00ff00;
}
.green {
color: #ff0000;
}
.blue {
color: #0000ff;
}
.lightgreen {
color: #ff00ff;
}
.lightblue {
color: #ffff00;
}
@Each
$headings: h1, h2, h3, h4, h5;
$size: 10px, 20px, 30px, 40px, 50px;
$head-size: zip($headings, $size);
@each $a in $head-size {
.display-#{nth($a, 1)} {
font-size: nth($a, 2);
}
}
Final Output
.display-h1 {
font-size: 10px;
}
.display-h2 {
font-size: 20px;
}
.display-h3 {
font-size: 30px;
}
.display-h4 {
font-size: 40px;
}
.display-h5 {
font-size: 50px;
}
@mixin
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.my-other-element {
@include border-radius(5px);
}
Final Output
.my-other-element {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
border-radius: 5px;
}
@mixin
@mixin transform-tilt() {
$tilt: rotate(15deg);
-webkit-transform: $tilt;
-ms-transform: $tilt;
transform: $tilt;
}
.frame {
@include transform-tilt;
}
Final Output
.frame {
-webkit-transform: rotate(15deg);
-ms-transform: rotate(15deg);
transform: rotate(15deg);
}
@mixin square($size, $color) {
width: $size;
height: $size;
background-color: $color;
}
.small-blue-square {
@include square(20px, rgb(0,0,255));
}
.big-red-square {
@include square(300px, rgb(255,0,0));
}
@mixin
Final Output
.small-blue-square {
width: 20px;
height: 20px;
background-color: #00f;
}
.big-red-square {
width: 300px;
height: 300px;
background-color: #f00;
}
Thank You

Mais conteúdo relacionado

Mais procurados

[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...
[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...
[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...
MongoDB
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
Dinu Suman
 
Aprils fool 2014
Aprils fool 2014Aprils fool 2014
Aprils fool 2014
bijan_
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2
ady36
 

Mais procurados (20)

The Perl6 Type System
The Perl6 Type SystemThe Perl6 Type System
The Perl6 Type System
 
[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...
[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...
[MongoDB.local Bengaluru 2018] Tutorial: Pipeline Power - Doing More with Mon...
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 
Mining the social web ch1
Mining the social web ch1Mining the social web ch1
Mining the social web ch1
 
Functional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipperFunctional pe(a)rls: Huey's zipper
Functional pe(a)rls: Huey's zipper
 
Линзы - комбинаторная манипуляция данными Александр Гранин Dev2Dev v2.0 30.05...
Линзы - комбинаторная манипуляция данными Александр Гранин Dev2Dev v2.0 30.05...Линзы - комбинаторная манипуляция данными Александр Гранин Dev2Dev v2.0 30.05...
Линзы - комбинаторная манипуляция данными Александр Гранин Dev2Dev v2.0 30.05...
 
Wsomdp
WsomdpWsomdp
Wsomdp
 
Ch1(introduction to php)
Ch1(introduction to php)Ch1(introduction to php)
Ch1(introduction to php)
 
Линзы - комбинаторная манипуляция данными (Dev2Dev)
Линзы - комбинаторная манипуляция данными (Dev2Dev)Линзы - комбинаторная манипуляция данными (Dev2Dev)
Линзы - комбинаторная манипуляция данными (Dev2Dev)
 
Aprils fool 2014
Aprils fool 2014Aprils fool 2014
Aprils fool 2014
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures edition
 
Inc
IncInc
Inc
 
Learning Perl 6
Learning Perl 6 Learning Perl 6
Learning Perl 6
 
PHP code examples
PHP code examplesPHP code examples
PHP code examples
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11
 
How-to Integração Postfi
How-to Integração PostfiHow-to Integração Postfi
How-to Integração Postfi
 
R57php 1231677414471772-2
R57php 1231677414471772-2R57php 1231677414471772-2
R57php 1231677414471772-2
 
McrFRED 39 | CSS Processors
McrFRED 39 | CSS ProcessorsMcrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
 
Bash Geekcamp
Bash GeekcampBash Geekcamp
Bash Geekcamp
 
Lecture19-20
Lecture19-20Lecture19-20
Lecture19-20
 

Semelhante a Sass

Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
Zeeshan Ahmed
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
Sway Wang
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Kaelig Deloumeau-Prigent
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
edgincvg
 

Semelhante a Sass (20)

Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
 
Sass - Making CSS fun again.
Sass - Making CSS fun again.Sass - Making CSS fun again.
Sass - Making CSS fun again.
 
How to Use Sass to Make Your Site More Maintainable
How to Use Sass to Make Your Site More MaintainableHow to Use Sass to Make Your Site More Maintainable
How to Use Sass to Make Your Site More Maintainable
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
FCIP SASS Talk
FCIP SASS TalkFCIP SASS Talk
FCIP SASS Talk
 
Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)Good Evils In Perl (Yapc Asia)
Good Evils In Perl (Yapc Asia)
 
Breakpoint
BreakpointBreakpoint
Breakpoint
 
Insertcustomer
InsertcustomerInsertcustomer
Insertcustomer
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
A better CSS: Sass and Less - CC FE & UX
A better CSS: Sass and Less - CC FE & UXA better CSS: Sass and Less - CC FE & UX
A better CSS: Sass and Less - CC FE & UX
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
 

Último

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Último (20)

%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 

Sass

  • 1. Sass ( Syntactically Awesome Style Sheets ) Scss (SCSS is called Sassy CSS) ( Sassy Cascading Style Sheets)
  • 2. // Sass $font-stack: Helvetica, sans-serif $primary-color: #333 body font: 100% $font-stack color: $primary-color // Scss $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } Final Output css body { font: 100% Helvetica, sans-serif; color: #333; } Syntax
  • 3. #plain-text { content: "I'm 1 + 2 years old"; } #interpolated { content: "I'm #{1 + 3} years old"; } 1 + 1 //2 (addition) 1 - 1 //0 (subtraction) 2 * 3 //6 (multiplication) (6 / 3) //2 (division, see below for an explanation of the parentheses) 5 % 2 //5 (modulus) Final Output #plain-text { content: "I'm 1 + 2 years old"; } #interpolated { content: "I'm 4 years old"; } Scss – Basic Arithmetic
  • 4. $width: 800px; .container-1 { width: $width; } .column-2 { width: $width / 2; } .column-3 { width: $width / 5; } Final Output .container-1 { width: 800px; } .column-2 { width: 400px; } .column-3 { width: 160px; } Scss – Basic Arithmetic
  • 5. #plain-text { content: "I'm 1 + 2 years old"; } #interpolated { content: "I'm #{1 + 3} years old"; } 5 < 3 //false (less than) 5 > 3 //true (greater than) 3 <= 3 //true (less than or equal to) 5 >= 3 //true (greater than or equal to) Final Output #plain-text { content: "I'm 1 + 2 years old"; } #interpolated { content: "I'm 4 years old"; } Scss – Comparison Operators
  • 6. $title-font: normal 24px/1.5 'Open Sans', sans-serif; $cool-red: #F44336; $box-shadow-bottom-only: 0 2px 1px 0 rgba(0, 0, 0, 0.2); h1.title { font: $title-font; color: $cool-red; } div.container { color: $cool-red; background: #fff; width: 100%; box-shadow: $box-shadow-bottom-only; } Final Output h1.title { font: normal 24px/1.5 "Open Sans", sans-serif; color: #F44336; } div.container { color: #F44336; background: #fff; width: 100%; box-shadow: 0 2px 1px 0 rgba(0, 0, 0, 0.2); } Scss - Variables
  • 7. Sass @-Rules and Directives @import @media @extend @include
  • 8. @Import // _reset.scss html, body, ul, ol { margin: 0; padding: 0; } // base.scss @import 'reset'; body { font: 100% Helvetica, sans-serif; background-color: #efefef; } Final Output html, body, ul, ol { margin: 0; padding: 0; } body { font: 100% Helvetica, sans-serif; background-color: #efefef; }
  • 9. @Media $size: 100px; .box { width:$size; @media (min-width: 800px) { width:$size + 50; @media (max-width: 1200px) { width:$size * 2; } } } Final Output .box { width: 100px; } @media (min-width: 800px) { .box { width: 150px; } } @media (min-width: 800px) and (max-width: 1200px) { .box { width: 200px; } }
  • 10. @Nesting ul { list-style: none; li { padding: 15px; display: inline-block; a { text-decoration: none; font-size: 16px; color: #444; } } } Final Output ul { list-style: none; } ul li { padding: 15px; display: inline-block; } ul li a { text-decoration: none; font-size: 16px; color: #444; }
  • 11. @Extend .dialog-button { box-sizing: border-box; color: #ffffff; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12); padding: 12px 40px; cursor: pointer; } .confirm { @extend .dialog-button; background-color: #87bae1; float: left; } .cancel { @extend .dialog-button; background-color: #e4749e; float: right; } Final Output .dialog-button, .confirm, .cancel { box-sizing: border-box; color: #fff; box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.12); padding: 12px 40px; cursor: pointer; } .confirm { background-color: #87bae1; float: left; } .cancel { background-color: #e4749e; float: right; }
  • 12. @for @for $i from 1 to 5 { .padding-#{$i} { padding: $i; } } Final Output .padding-1 { padding: 1; } .padding-2 { padding: 2; } .padding-3 { padding: 3; } .padding-4 { padding: 4; } @for $i from 1 through 5 { .padding-#{$i}{ padding: $i;} } Final Output .padding-1 { padding: 1; } .padding-2 { padding: 2; } .padding-3 { padding: 3; } .padding-4 { padding: 4; } .padding-5 { padding: 5; }
  • 13. @for $color: "blue", "green", "orange", "red", "pink", "grey", "black"; @for $i from 1 through length($color){ .color-#{ nth($color, $i) } { color: #{ nth($color, $i) } } } Final Output .color-blue { color: blue; } .color-green { color: green; } .color-orange { color: orange; } .color-red { color: red; } .color-pink { color: pink; } .color-grey { color: grey; }
  • 14. @while $i: 1; @while $i <= 5 { wd-#{$i}{ width: #{$i}; } $i: $i + 1; } Final Output wd-1 { width: 1; } wd-2 { width: 2; } wd-3 { width: 3; } wd-4 { width: 4; } wd-5 { width: 5; }
  • 15. @Each $colour: ( red: #00ff00, green: #ff0000, blue: #0000ff, lightgreen: #ff00ff, lightblue: #ffff00); @each $labelname, $colouritem in $colour { .#{$labelname} { color: $colouritem; } } Final Output .red { color: #00ff00; } .green { color: #ff0000; } .blue { color: #0000ff; } .lightgreen { color: #ff00ff; } .lightblue { color: #ffff00; }
  • 16. @Each $headings: h1, h2, h3, h4, h5; $size: 10px, 20px, 30px, 40px, 50px; $head-size: zip($headings, $size); @each $a in $head-size { .display-#{nth($a, 1)} { font-size: nth($a, 2); } } Final Output .display-h1 { font-size: 10px; } .display-h2 { font-size: 20px; } .display-h3 { font-size: 30px; } .display-h4 { font-size: 40px; } .display-h5 { font-size: 50px; }
  • 17. @mixin @mixin border-radius($radius) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius; } .my-other-element { @include border-radius(5px); } Final Output .my-other-element { -webkit-border-radius: 5px; -moz-border-radius: 5px; -ms-border-radius: 5px; border-radius: 5px; }
  • 18. @mixin @mixin transform-tilt() { $tilt: rotate(15deg); -webkit-transform: $tilt; -ms-transform: $tilt; transform: $tilt; } .frame { @include transform-tilt; } Final Output .frame { -webkit-transform: rotate(15deg); -ms-transform: rotate(15deg); transform: rotate(15deg); }
  • 19. @mixin square($size, $color) { width: $size; height: $size; background-color: $color; } .small-blue-square { @include square(20px, rgb(0,0,255)); } .big-red-square { @include square(300px, rgb(255,0,0)); } @mixin Final Output .small-blue-square { width: 20px; height: 20px; background-color: #00f; } .big-red-square { width: 300px; height: 300px; background-color: #f00; }