SASS Preprocessor

Webkul Software Pvt. Ltd.
Webkul Software Pvt. Ltd.Webkul Software Pvt. Ltd.
SASS
(Syntactically Awesome Style Sheet)
Introduction
● Sass is an extension of CSS3, adding nested rules, variables, mixins, selector
inheritance, and more. It’s translated to well-formatted, standard CSS using the
command line tool or a web-framework plugin.
● Sass has two syntaxes. The new main syntax (as of Sass 3) is known as “SCSS” (for
“Sassy CSS”). SCSS files use the extension .scss.
Install Sass
(Applications)
There are a good many applications that will get you up and running with Sass in a few
minutes for Mac, Windows, and Linux. You can download most of the applications for
free but a few of them are paid apps.
CodeKit (Paid)
Compass.app (Paid, Open Source)
Hammer (Paid)
Koala (Open Source)
LiveReload (Paid, Open Source)
Mixture (Free)
Prepros (Paid)
Scout (Open Source)
Install Sass and Compass
•Sass and Compass get installed as Ruby gems so you'll
need to have Ruby on your machine.
•If you're on Windows, you can run the Ruby Installer.
On Linux, Rails Ready provides several Ruby essentials.
On OS X, Ruby is already installed by default so Ruby
just works.
Install Sass
•Open up your Terminal.app and type:
•Windows:
gem install compass
•Linux / OS X:
sudo gem install compass
Features
•Variables
•Nesting
•Partials
•Import
•Mixins
•Extend/Inheritance
•Operators
Variables
SASS SCSS
$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;
}
CSS
body {
font: 100% Helvetica, sans-serif;
color: #333;
}
Nesting
SASS SCSS
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;
}
li {
display: inline-block;
}
a {
display: block;
padding: 6px 12px;
text-decoration: none;
}
}
CSS
nav ul { margin: 0; padding: 0; list-style: none; }
nav li { display: inline-block; }
nav a { display: block; padding: 6px 12px; text-decoration: none; }
ImportSASS SCSS
// _reset.sass
html, body, ul, ol
margin: 0
padding: 0
// base.sass
@import reset
body
font: 100% Helvetica, sans-serif
background-color: #efefef
// _reset.scss
html, body, ul, ol {
margin: 0; padding: 0;
}
/* base.scss */
@import 'reset';
body {
font: 100% Helvetica, sans-serif; background-color:
#efefef;
}
CSS
html, body, ul, ol {
margin: 0; padding: 0;
}
body {
font: 100% Helvetica, sans-serif; background-color: #efefef;
}
MixinsSASS SCSS
=border-radius($radius)
-webkit-border-radius: $radius
-moz-border-radius: $radius
-ms-border-radius: $radius
border-radius: $radius
.box
+border-radius(10px)
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.box {
@include border-radius(10px);
}
CSS
.box {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
}
Extend/InheritanceSASS SCSS
.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 {
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;
}
CSS
.message, .success, .error, .warning {
border: 1px solid #cccccc; padding: 10px; color: #333;
}
.success { border-color: green; }
.error { border-color: red; }
.warning { border-color: yellow; }
OperatorsSASS SCSS
.container
width: 100%
article
float: left
width: 600px / 960px * 100%
aside
float: right
width: 300px / 960px * 100%
.container {
width: 100%;
}
article {
float: left;
width: 600px / 960px * 100%;
}
aside {
float: right;
width: 300px / 960px * 100%;
}
CSS
.container {
width: 100%;
}
article { float: left; width: 62.5%; }
aside { float: right; width: 31.25%; }
Breakpoints
@mixin breakpoint($query) {
@media #{$query} { @content; }
}
$small-phone-and-down: "screen and (max-width: " + pxToEm(319) + ")";
$large-phone-and-up: "screen and (min-width: " + pxToEm(400) + ")";
$large-desktop-and-down: "screen and (max-width: #{$width-frame-max})";
body {
@include breakpoint($large-phone-and-up) { font-size: 1.1em; }
}
@include breakpoint($small-phone-and-down) {
.main-menu {
background-color: $color-menu-background;
a {
color: $color-menu-link;
}
}
}
Thank you!
1 von 14

Recomendados

Syntactically awesome stylesheets (Sass) von
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Tahmina Khatoon
2.5K views47 Folien
Write LESS. DO more. von
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.Eugene Nor
658 views30 Folien
Dallas Drupal Days 2012 - Introduction to less sass-compass von
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compassChris Lee
2K views41 Folien
CSS Preprocessors: LESS is more or look SASS-y trying von
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingJames Cryer
1.9K views19 Folien
Sass von
SassSass
SassTayseer_Emam
377 views15 Folien
Introduction to sass von
Introduction to sassIntroduction to sass
Introduction to sassAnoop Raveendran
984 views22 Folien

Más contenido relacionado

Was ist angesagt?

Less(CSS Pre Processor) Introduction von
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introductionrushi7567
58 views24 Folien
Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016 von
Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016
Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016Matt Vanderpol
502 views80 Folien
Infrastructure as code terraformujeme cloud von
Infrastructure as code   terraformujeme cloudInfrastructure as code   terraformujeme cloud
Infrastructure as code terraformujeme cloudViliamPucik
57 views30 Folien
Start using less css von
Start using less cssStart using less css
Start using less cssAli MasudianPour
2.9K views13 Folien
LESS CSS von
LESS CSSLESS CSS
LESS CSSMathi Rajalingam
743 views24 Folien
Less presentation von
Less presentationLess presentation
Less presentationTodd Shelton
2.8K views12 Folien

Was ist angesagt?(6)

Less(CSS Pre Processor) Introduction von rushi7567
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introduction
rushi756758 views
Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016 von Matt Vanderpol
Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016
Building Custom WordPress Themes with Sass - WordCamp Sacramento 2016
Matt Vanderpol502 views
Infrastructure as code terraformujeme cloud von ViliamPucik
Infrastructure as code   terraformujeme cloudInfrastructure as code   terraformujeme cloud
Infrastructure as code terraformujeme cloud
ViliamPucik57 views

Destacado

Pre-procesadores CSS. SASS von
Pre-procesadores CSS. SASSPre-procesadores CSS. SASS
Pre-procesadores CSS. SASSMarionaCruz
5.3K views26 Folien
CSS von
CSSCSS
CSSMARTINGVALLE
1K views100 Folien
Css von
CssCss
CssMariela Tapia
698 views38 Folien
Guía Básica de CSS von
Guía Básica de CSSGuía Básica de CSS
Guía Básica de CSSMariano Jofre
594 views41 Folien
Introduccion a CSS I von
Introduccion a CSS IIntroduccion a CSS I
Introduccion a CSS IHéctor Estigarribia
921 views90 Folien
Html css von
Html cssHtml css
Html cssVanesa Naimad
331 views28 Folien

Destacado(20)

Pre-procesadores CSS. SASS von MarionaCruz
Pre-procesadores CSS. SASSPre-procesadores CSS. SASS
Pre-procesadores CSS. SASS
MarionaCruz5.3K views
Front End - Maquetación xhtml + css von zara hormazabal
Front End - Maquetación xhtml + cssFront End - Maquetación xhtml + css
Front End - Maquetación xhtml + css
zara hormazabal2.6K views
CSS - ¿Cómo agregar estilos a mi página? von Harold Maduro
CSS - ¿Cómo agregar estilos a mi página?CSS - ¿Cómo agregar estilos a mi página?
CSS - ¿Cómo agregar estilos a mi página?
Harold Maduro8.9K views
Fanzine 3 - Colectivo Miles de Voces von milesdevoces
Fanzine 3 - Colectivo Miles de VocesFanzine 3 - Colectivo Miles de Voces
Fanzine 3 - Colectivo Miles de Voces
milesdevoces561 views
Tips para el plan de negocios - Parte 1 von Maria Laura Cuya
Tips para el plan de negocios - Parte 1Tips para el plan de negocios - Parte 1
Tips para el plan de negocios - Parte 1
Maria Laura Cuya489 views
Free Library Briefing von free_library
Free Library Briefing Free Library Briefing
Free Library Briefing
free_library365 views
第0回ワススタ!! #wasbookを読もう von Tatsuya Tobioka
第0回ワススタ!! #wasbookを読もう第0回ワススタ!! #wasbookを読もう
第0回ワススタ!! #wasbookを読もう
Tatsuya Tobioka1.2K views
Email marketing von maosongppt
Email marketingEmail marketing
Email marketing
maosongppt361 views

Similar a SASS Preprocessor

SASS, Compass, Gulp, Greensock von
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
1.3K views43 Folien
CSS 開發加速指南-Sass & Compass von
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
2.5K views61 Folien
CSS3 von
CSS3CSS3
CSS3Chathuranga Jayanath
252 views60 Folien
UNIT 3.ppt von
UNIT 3.pptUNIT 3.ppt
UNIT 3.pptkavi806657
11 views99 Folien
Simple introduction Sass von
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
501 views26 Folien
Modularization css with sass von
Modularization css with sassModularization css with sass
Modularization css with sassHuiyi Yan
625 views13 Folien

Similar a SASS Preprocessor(20)

SASS, Compass, Gulp, Greensock von Marco Pinheiro
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
Marco Pinheiro1.3K views
CSS 開發加速指南-Sass & Compass von Lucien Lee
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
Lucien Lee2.5K views
Modularization css with sass von Huiyi Yan
Modularization css with sassModularization css with sass
Modularization css with sass
Huiyi Yan625 views
Fasten RWD Development with Sass von Sven Wolfermann
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
Sven Wolfermann5.2K views
Using Sass - Building on CSS von Sayanee Basu
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
Sayanee Basu1K views
LESS : The dynamic stylesheet language von Katsunori Tanaka
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
Katsunori Tanaka3.3K views
An Introduction to CSS Preprocessors (SASS & LESS) von Folio3 Software
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
Folio3 Software1.6K views
SASS is more than LESS von Itai Koren
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
Itai Koren1.2K views
Sass & Compass (Barcamp Stuttgart 2012) von emrox
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
emrox3.3K views
Syntactically Awesome Stylesheet - A workshop by Citytech Software von Ritwik Das
Syntactically Awesome Stylesheet - A workshop by Citytech SoftwareSyntactically Awesome Stylesheet - A workshop by Citytech Software
Syntactically Awesome Stylesheet - A workshop by Citytech Software
Ritwik Das39 views
Sass:-Syntactically Awesome Stylesheet by Shafeeq von DignitasDigital1
Sass:-Syntactically Awesome Stylesheet by ShafeeqSass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by Shafeeq
DignitasDigital1629 views
Bliblidotcom - SASS Introduction von Irfan Maulana
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS Introduction
Irfan Maulana977 views
Authoring Stylesheets with Compass & Sass von chriseppstein
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
chriseppstein5K views
Preprocessor presentation von Mario Noble
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
Mario Noble1.3K views

Más de Webkul Software Pvt. Ltd.

Quick Product Edit for Magento 2 von
Quick Product Edit for Magento 2Quick Product Edit for Magento 2
Quick Product Edit for Magento 2Webkul Software Pvt. Ltd.
70 views11 Folien
Language translator for magento 2 von
Language translator for magento 2Language translator for magento 2
Language translator for magento 2Webkul Software Pvt. Ltd.
34 views11 Folien
Magento 2 marketplace flutterwave payment von
 Magento 2 marketplace flutterwave payment  Magento 2 marketplace flutterwave payment
Magento 2 marketplace flutterwave payment Webkul Software Pvt. Ltd.
46 views11 Folien
OpenCart Ebay Connector Plugin von
OpenCart Ebay Connector PluginOpenCart Ebay Connector Plugin
OpenCart Ebay Connector PluginWebkul Software Pvt. Ltd.
29 views15 Folien
Magento 2 Geo-Location Currency Converter von
Magento 2 Geo-Location Currency ConverterMagento 2 Geo-Location Currency Converter
Magento 2 Geo-Location Currency ConverterWebkul Software Pvt. Ltd.
32 views15 Folien
Etsy Connector for Magento 2 von
Etsy Connector for Magento 2Etsy Connector for Magento 2
Etsy Connector for Magento 2Webkul Software Pvt. Ltd.
25 views15 Folien

Más de Webkul Software Pvt. Ltd.(20)

Último

2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue von
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
103 views23 Folien
State of the Union - Rohit Yadav - Apache CloudStack von
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStackShapeBlue
253 views53 Folien
Uni Systems for Power Platform.pptx von
Uni Systems for Power Platform.pptxUni Systems for Power Platform.pptx
Uni Systems for Power Platform.pptxUni Systems S.M.S.A.
61 views21 Folien
Why and How CloudStack at weSystems - Stephan Bienek - weSystems von
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsShapeBlue
197 views13 Folien
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... von
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...ShapeBlue
98 views29 Folien
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... von
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...ShapeBlue
146 views15 Folien

Último(20)

2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue von ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue103 views
State of the Union - Rohit Yadav - Apache CloudStack von ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue253 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems von ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue197 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... von ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue98 views
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ... von ShapeBlue
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
Backroll, News and Demo - Pierre Charton, Matthias Dhellin, Ousmane Diarra - ...
ShapeBlue146 views
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue von ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlueMigrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
Migrating VMware Infra to KVM Using CloudStack - Nicolas Vazquez - ShapeBlue
ShapeBlue176 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue von ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue163 views
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T von ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue112 views
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P... von ShapeBlue
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
Developments to CloudStack’s SDN ecosystem: Integration with VMWare NSX 4 - P...
ShapeBlue154 views
Future of AR - Facebook Presentation von Rob McCarty
Future of AR - Facebook PresentationFuture of AR - Facebook Presentation
Future of AR - Facebook Presentation
Rob McCarty62 views
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... von ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue85 views
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... von ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue123 views
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... von Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker50 views
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha... von ShapeBlue
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
Mitigating Common CloudStack Instance Deployment Failures - Jithin Raju - Sha...
ShapeBlue138 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... von TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc160 views
Business Analyst Series 2023 - Week 4 Session 7 von DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray10126 views
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... von ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue120 views

SASS Preprocessor

  • 2. Introduction ● Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin. ● Sass has two syntaxes. The new main syntax (as of Sass 3) is known as “SCSS” (for “Sassy CSS”). SCSS files use the extension .scss.
  • 3. Install Sass (Applications) There are a good many applications that will get you up and running with Sass in a few minutes for Mac, Windows, and Linux. You can download most of the applications for free but a few of them are paid apps. CodeKit (Paid) Compass.app (Paid, Open Source) Hammer (Paid) Koala (Open Source) LiveReload (Paid, Open Source) Mixture (Free) Prepros (Paid) Scout (Open Source)
  • 4. Install Sass and Compass •Sass and Compass get installed as Ruby gems so you'll need to have Ruby on your machine. •If you're on Windows, you can run the Ruby Installer. On Linux, Rails Ready provides several Ruby essentials. On OS X, Ruby is already installed by default so Ruby just works.
  • 5. Install Sass •Open up your Terminal.app and type: •Windows: gem install compass •Linux / OS X: sudo gem install compass
  • 7. Variables SASS SCSS $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; } CSS body { font: 100% Helvetica, sans-serif; color: #333; }
  • 8. Nesting SASS SCSS 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; } li { display: inline-block; } a { display: block; padding: 6px 12px; text-decoration: none; } } CSS nav ul { margin: 0; padding: 0; list-style: none; } nav li { display: inline-block; } nav a { display: block; padding: 6px 12px; text-decoration: none; }
  • 9. ImportSASS SCSS // _reset.sass html, body, ul, ol margin: 0 padding: 0 // base.sass @import reset body font: 100% Helvetica, sans-serif background-color: #efefef // _reset.scss html, body, ul, ol { margin: 0; padding: 0; } /* base.scss */ @import 'reset'; body { font: 100% Helvetica, sans-serif; background-color: #efefef; } CSS html, body, ul, ol { margin: 0; padding: 0; } body { font: 100% Helvetica, sans-serif; background-color: #efefef; }
  • 10. MixinsSASS SCSS =border-radius($radius) -webkit-border-radius: $radius -moz-border-radius: $radius -ms-border-radius: $radius border-radius: $radius .box +border-radius(10px) @mixin border-radius($radius) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius; } .box { @include border-radius(10px); } CSS .box { -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; border-radius: 10px; }
  • 11. Extend/InheritanceSASS SCSS .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 { 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; } CSS .message, .success, .error, .warning { border: 1px solid #cccccc; padding: 10px; color: #333; } .success { border-color: green; } .error { border-color: red; } .warning { border-color: yellow; }
  • 12. OperatorsSASS SCSS .container width: 100% article float: left width: 600px / 960px * 100% aside float: right width: 300px / 960px * 100% .container { width: 100%; } article { float: left; width: 600px / 960px * 100%; } aside { float: right; width: 300px / 960px * 100%; } CSS .container { width: 100%; } article { float: left; width: 62.5%; } aside { float: right; width: 31.25%; }
  • 13. Breakpoints @mixin breakpoint($query) { @media #{$query} { @content; } } $small-phone-and-down: "screen and (max-width: " + pxToEm(319) + ")"; $large-phone-and-up: "screen and (min-width: " + pxToEm(400) + ")"; $large-desktop-and-down: "screen and (max-width: #{$width-frame-max})"; body { @include breakpoint($large-phone-and-up) { font-size: 1.1em; } } @include breakpoint($small-phone-and-down) { .main-menu { background-color: $color-menu-background; a { color: $color-menu-link; } } }