SlideShare a Scribd company logo
1 of 22
SASS
(Syntactically Awesome Style
Sheets)
Anoop P R
Senior Software Engineer
Experion Technologies
CSS Problems
•Repetitive
•Not expressive
•No variables
•No functions
•No calculation
•No inheritance etc.
What is Sass?
•SASS is a system that extends CSS and can make you
more efficient and make your CSS more organized.
•Serves as
Scripting language
Preprocessor for CSS
SASS has two main parts
•SassScript (.sass & .scss)
SassScript is a scripting language that extends the CSS syntax,
adding nested rules, variables, mixins.
•SASS CSS pre-processor
The pre-processor interprets your SassScript and produces well
formatted standard CSS.
SASS Syntax
body
font: 100% $font-stack
color: $primary-color
body {
font: 100% $font-stack;
color: $primary-color;
}
.sass
.scss
The process
•Write your SassScript
•Use CSS pre-processor to interpret your SassScript
•CSS files are produced by the pre‐processor (use
these in your website)
What sass offers
•Variables
•Nesting
•Mixins
•Partials
•Selector inheritance
•Calculations
•Conditions
Variables
•Variables allow you to assign a value to an easy-to-
remember placeholder name
Works with hex values, strings of text, colors, numbers, boolean
values etc.
No more memorizing hex values!
Variables
h1#master {
color: #f00;
}
.post-hd {
color: #ff0000;
}
a.outline {
color: red;
}
.sidebar p {
color: rgba(255, 0, 0, 1);
}
css scss
$base-color : red;
h1#master {
color: $base-color;
}
.post-hd {
color: $base-color;
}
a.outline {
color: $base-color;
}
.sidebar p {
color: $base-color;
}
Nesting
•Nested rules allow you to break up endlessly long
selectors of CSS
Nesting
.nav ul {
margin: 0;
padding: 0;
list-style: none;
}
.nav ul li {
display: inline-block;
}
.nav ul a {
display: block;
padding: 6px 12px;
text-decoration: none;
}
.nav ul a:hover {
color: #fff;
}
css scss
.nav {
ul {
margin: 0;
padding: 0;
list-style: none;
li {
display: inline-block;
}
}
a {
display: block;
padding: 6px 12px;
text-decoration: none;
&:hover {
color: #fff;
}
}
}
Nesting (properties)
.selected-text {
font-family: "Georgia", Times, serif;
font-style: oblique;
font-size: 12px;
}
.selcted-text {
font {
family: "Georgia", Times, serif;
style: oblique;
size: 12px;
}
}
css
sass
Mixins
•Mixins allow you to chunk up CSS declarations to be
reusable with one reference.
•Reusable code
Mixins
.box-1 {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
}
.box-2 {
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
-ms-border-radius: 25px;
border-radius: 25px;
}
css
Mixins
.box-1 {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
}
.box-2 {
-webkit-border-radius: 25px;
-moz-border-radius: 25px;
-ms-border-radius: 25px;
border-radius: 25px;
}
css scss
@mixin border-radius($radius: 12px) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.box-0 {@include border-radius;}
.box-1 { @include border-radius(10px); }
.box-2 { @include border-radius(25px); }
Tip: Mixins can reference mixins as well
Selector inheritance
•Inheritance imports syntax and styles from another
selection.
Selector inheritance
.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;
}
scss css
.message, .success, .error, .warning {
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
border-color: green;
}
.error {
border-color: red;
}
.warning {
border-color: yellow;
}
Partials
•You can create partial Sass files that contain little
snippets of CSS that you can include in other Sass files.
•A partial is simply a Sass file named with a leading
underscore.
•Sass partials are used with the @import directive.
_buttons.scss
_navigation.scss
genaral.sass
@import "buttons", "navigation";
Arithmetic operations
•Sass has a handful of standard math operators like +, -, *,
/, and %
.main-article {
float: left;
width: 600px / 960px * 100%;
}
Conditions
$type: monster;
p {
@if $type == ocean {
color: blue;
}
@else if $type == matador {
color: red;
}
@else if $type == monster {
color: green;
}
@else {
color: black;
}
}
SASS Compilation
•Install Sass
•SASS to CSS
•Watch sass file
gem install sass
sass input.scss output.css
sass --watch input.scss:output.css
Thank You!

More Related Content

What's hot

CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transformKenny Lee
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media QueriesRuss Weakley
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid LayoutRachel Andrew
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers10Clouds
 
Intro to css & sass
Intro to css & sassIntro to css & sass
Intro to css & sassSean Wolfe
 
CSS Dasar #2 : Anatomy CSS
CSS Dasar #2 : Anatomy CSSCSS Dasar #2 : Anatomy CSS
CSS Dasar #2 : Anatomy CSSSandhika Galih
 
CSS Dasar #3 : Penempatan CSS
CSS Dasar #3 : Penempatan CSSCSS Dasar #3 : Penempatan CSS
CSS Dasar #3 : Penempatan CSSSandhika Galih
 
Front End Best Practices
Front End Best PracticesFront End Best Practices
Front End Best PracticesHolger Bartel
 
Sass: CSS con Superpoderes
Sass: CSS con SuperpoderesSass: CSS con Superpoderes
Sass: CSS con SuperpoderesEdgar Parada
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEMVarya Stepanova
 
Intro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS PropertyIntro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS PropertyAdam Soucie
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid LayoutRachel Andrew
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTMLAjay Khatri
 

What's hot (20)

Sass
SassSass
Sass
 
CSS3 2D/3D transform
CSS3 2D/3D transformCSS3 2D/3D transform
CSS3 2D/3D transform
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
 
Less vs sass
Less vs sassLess vs sass
Less vs sass
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers
 
Intro to css & sass
Intro to css & sassIntro to css & sass
Intro to css & sass
 
CSS Best practice
CSS Best practiceCSS Best practice
CSS Best practice
 
CSS Dasar #2 : Anatomy CSS
CSS Dasar #2 : Anatomy CSSCSS Dasar #2 : Anatomy CSS
CSS Dasar #2 : Anatomy CSS
 
Css pseudo-classes
Css pseudo-classesCss pseudo-classes
Css pseudo-classes
 
CSS Dasar #3 : Penempatan CSS
CSS Dasar #3 : Penempatan CSSCSS Dasar #3 : Penempatan CSS
CSS Dasar #3 : Penempatan CSS
 
Front End Best Practices
Front End Best PracticesFront End Best Practices
Front End Best Practices
 
Sass: CSS con Superpoderes
Sass: CSS con SuperpoderesSass: CSS con Superpoderes
Sass: CSS con Superpoderes
 
CSS Lists and Tables
CSS Lists and TablesCSS Lists and Tables
CSS Lists and Tables
 
CSS 語法教學
CSS 語法教學CSS 語法教學
CSS 語法教學
 
CSS Dasar #1 : Intro
CSS Dasar #1 : IntroCSS Dasar #1 : Intro
CSS Dasar #1 : Intro
 
BEM it! Introduction to BEM
BEM it! Introduction to BEMBEM it! Introduction to BEM
BEM it! Introduction to BEM
 
Intro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS PropertyIntro to Flexbox - A Magical CSS Property
Intro to Flexbox - A Magical CSS Property
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid Layout
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 

Similar to Introduction to sass

Similar to Introduction to sass (20)

Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
PostCss
PostCssPostCss
PostCss
 
Make your CSS beautiful again
Make your CSS beautiful againMake your CSS beautiful again
Make your CSS beautiful again
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
Peggy sass vs scss
Peggy  sass vs scssPeggy  sass vs scss
Peggy sass vs scss
 
Compass n Sass
Compass n SassCompass n Sass
Compass n Sass
 
Why are we using Sass to create Grid Frameworks?
Why are we using Sass to create Grid Frameworks?Why are we using Sass to create Grid Frameworks?
Why are we using Sass to create Grid Frameworks?
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
 
Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 
Understanding sass
Understanding sassUnderstanding sass
Understanding sass
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
SASS Lecture
SASS Lecture SASS Lecture
SASS Lecture
 
CSS3
CSS3CSS3
CSS3
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
SASS Preprocessor
SASS PreprocessorSASS Preprocessor
SASS Preprocessor
 
LESS CSS
LESS CSSLESS CSS
LESS CSS
 
Sass compass
Sass compassSass compass
Sass compass
 

Recently uploaded

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Introduction to sass

  • 1. SASS (Syntactically Awesome Style Sheets) Anoop P R Senior Software Engineer Experion Technologies
  • 2. CSS Problems •Repetitive •Not expressive •No variables •No functions •No calculation •No inheritance etc.
  • 3. What is Sass? •SASS is a system that extends CSS and can make you more efficient and make your CSS more organized. •Serves as Scripting language Preprocessor for CSS
  • 4. SASS has two main parts •SassScript (.sass & .scss) SassScript is a scripting language that extends the CSS syntax, adding nested rules, variables, mixins. •SASS CSS pre-processor The pre-processor interprets your SassScript and produces well formatted standard CSS.
  • 5. SASS Syntax body font: 100% $font-stack color: $primary-color body { font: 100% $font-stack; color: $primary-color; } .sass .scss
  • 6. The process •Write your SassScript •Use CSS pre-processor to interpret your SassScript •CSS files are produced by the pre‐processor (use these in your website)
  • 8. Variables •Variables allow you to assign a value to an easy-to- remember placeholder name Works with hex values, strings of text, colors, numbers, boolean values etc. No more memorizing hex values!
  • 9. Variables h1#master { color: #f00; } .post-hd { color: #ff0000; } a.outline { color: red; } .sidebar p { color: rgba(255, 0, 0, 1); } css scss $base-color : red; h1#master { color: $base-color; } .post-hd { color: $base-color; } a.outline { color: $base-color; } .sidebar p { color: $base-color; }
  • 10. Nesting •Nested rules allow you to break up endlessly long selectors of CSS
  • 11. Nesting .nav ul { margin: 0; padding: 0; list-style: none; } .nav ul li { display: inline-block; } .nav ul a { display: block; padding: 6px 12px; text-decoration: none; } .nav ul a:hover { color: #fff; } css scss .nav { ul { margin: 0; padding: 0; list-style: none; li { display: inline-block; } } a { display: block; padding: 6px 12px; text-decoration: none; &:hover { color: #fff; } } }
  • 12. Nesting (properties) .selected-text { font-family: "Georgia", Times, serif; font-style: oblique; font-size: 12px; } .selcted-text { font { family: "Georgia", Times, serif; style: oblique; size: 12px; } } css sass
  • 13. Mixins •Mixins allow you to chunk up CSS declarations to be reusable with one reference. •Reusable code
  • 14. Mixins .box-1 { -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; border-radius: 10px; } .box-2 { -webkit-border-radius: 25px; -moz-border-radius: 25px; -ms-border-radius: 25px; border-radius: 25px; } css
  • 15. Mixins .box-1 { -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; border-radius: 10px; } .box-2 { -webkit-border-radius: 25px; -moz-border-radius: 25px; -ms-border-radius: 25px; border-radius: 25px; } css scss @mixin border-radius($radius: 12px) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius; } .box-0 {@include border-radius;} .box-1 { @include border-radius(10px); } .box-2 { @include border-radius(25px); } Tip: Mixins can reference mixins as well
  • 16. Selector inheritance •Inheritance imports syntax and styles from another selection.
  • 17. Selector inheritance .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; } scss css .message, .success, .error, .warning { border: 1px solid #ccc; padding: 10px; color: #333; } .success { border-color: green; } .error { border-color: red; } .warning { border-color: yellow; }
  • 18. Partials •You can create partial Sass files that contain little snippets of CSS that you can include in other Sass files. •A partial is simply a Sass file named with a leading underscore. •Sass partials are used with the @import directive. _buttons.scss _navigation.scss genaral.sass @import "buttons", "navigation";
  • 19. Arithmetic operations •Sass has a handful of standard math operators like +, -, *, /, and % .main-article { float: left; width: 600px / 960px * 100%; }
  • 20. Conditions $type: monster; p { @if $type == ocean { color: blue; } @else if $type == matador { color: red; } @else if $type == monster { color: green; } @else { color: black; } }
  • 21. SASS Compilation •Install Sass •SASS to CSS •Watch sass file gem install sass sass input.scss output.css sass --watch input.scss:output.css