SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Downloaden Sie, um offline zu lesen
SASS ESSENTIALS
Sass: Syntactically Awesome Style Sheets
@romiguelangel
: About me
Miguel Ángel Ríos | @romiguelangel
Frontend Developer at
and
: What is SASS ?
SASS is a pseudo-language that adds
superpowers to your css, allowing use variables,
functions, control statements, inheritance,
interpolation, etc ..
: How can SASS help you ?
Scalability
Maintenance
Increase development speed
Apply DRY (Don’t Repeat Yourself)
More control over the code
Apply Clean Code principles
...
: How it say ? SASS or SCSS ?
You can type SASS with two syntaxes :
body
font-family: $font-base
background-color: white
p, a
font-size: $size-base
h1, .h1
font-size: $size-base * 1.5
a
text-decoration: none
&, &:active, &:visited
color: black
&:hover
+transition(color, 0.25s)
color: $color-selected
SASS
Don't use brackets or semicolons
.SASS file extension
Elements indentation set specification
level of your selectors
: How it say ? SASS or SCSS ?
body {
font-family: $font-base;
background-color: white; }
p, a {
font-size: $size-base; }
h1, .h1 {
font-size: $size-base * 1.5 }
a {
text-decoration: none;
&, &:active, &:visited {
color: black; }
&:hover {
@include transition(color, 0.25s);
color: $color-selected; }
}
SCSS
Use brackets and semicolons
.SCSS file extension
Every valid CSS3 stylesheet is a valid
SCSS
CSS
SCSS
You can type SASS with two syntaxes :
: but, How can I install it ?
Open a terminal and :
# Require ruby
$ gem install sass
# Test
$ sass -v
Sass 3.3.4 (Maptastic Maple)
: All right, how can I convert my css ?
$ sass-convert [input] [output]
# CSS to SASS
$ sass-convert main.css main.sass
# CSS to SCSS
$ mv main.css main.scss
# SCSS to SASS
$ sass-convert main.scss main.sass
Open a terminal and :
: Processing CSS
$ sass [--option] [input]:[output]
# Create or update main.css once
$ sass --update main.sass:main.css
# Active watcher and update main.css by each change
$ sass --watch main.sass:main.css
# Compile all folder files into css folder
$ sass --watch .:../css
# Output compressed in one line
$ sass --watch .:../css --style compressed
Leave open a terminal and :
: Variables $
Prefixed with $ symbol
Can be colors, values, fonts, arithmetic
operations, etc ..
Can contain more than one item,
making a list that can be traveled with
a control statement.
$font-base: arial, sans-serif
$color-base: #333333
$color-selected: #FFA500
$size-base: 12px
$size-large: $size-base * 1.5
body
font:
family: $font-base
size: $size-base
h1, .h1
font-size: $size-large
a
color: $color-base
&:hover
color: $color-selected
Store information and reused after
: Nesting
Keep nesting proportion. e.g. If you
indent first with n tabs, you need to use
the same tabs for all levels of nesting.
You can indent with tabs or spaces,
but not both at once.
It’s recommended to not exceed the 3
levels of indentation, to avoid high
levels of specification in the output
file.
.product
display: inline-block
.product-header
text-align: center
.product-content
max-height: 300px
.product-footer
background-color: #EEE
li
float: left
margin-right: 10px
&:last-child
margin: 0
N1 N2 N3
Clear hierarchy thanks to indentation
: Partials & Imports
We can import other style files
(partials) to build our output file.
There are two partials types :
Without underscore e.g. buttons.sass
Generates an output file css also
included in the parent file.
With underscore e.g. _buttons.sass
NO generates output file, are only
included in the parent file.
// inside of main.sass
@import _reset.sass
@import media.sass
Load different modules to make your css
_reset main media
main media
CSS
SASS
: Mixins
To declare can be used both prefixes :
= or @mixin
Once generated will be included with
the @include or + sign followed by the
name of the mixin and its arguments
Don’t need arguments, you can only
generate blocks with styles
@mixin border-radius($radius)
-webkit-border-radius: $radius
-moz-border-radius: $radius
border-radius: $radius
=clearfix
display: inline-block
&:after
content: "."
display: block
height: 0
clear: both
visibility: hidden
* html &
height: 1px
.block
+border-radius(10px)
@include clearfix
Encapsule styles and use like a function
: @Extend and %placeholders
Using @extend inherit all the
properties of the element we need
The %placeholders avoid generating
the root element in the output file,
reducing our code and making it more
semantic
It’s not recommended to extend major
selectors (h1, ul, li, etc ..), it could
generate inheritance loops
%button-base
display: inline-block
text-align: center
padding: 5px 10px
cursor: pointer
border: 1px solid #BBB
.button-success
@extend %button-base
background-color: green
.button-remove
@extend %button-base
background-color: red
.button-remove-disabled
@extend .button-remove
pointer-events: none
Inheritance from selectors and classes
: Interpolation
We will use #{$var} to put a variable
inside a string, class, id or to generate
a property.
// Into elements
$color: red
.button-#{$color}
color: $color
// Into strings
$sprite: ‘sprite27.png’
.icon-home
background: url(‘img/#{$sprite}’)
// Into properties
$property: border-radius
$values: 10px
=super-mixin($property, $values)
-webkit-#{$property}: $values
-moz-#{$property}: $values
#{$property}: $values
Variables into elements, strings and properties
: Operations & Basic functions
$grid: 12 // max columns
$margins: 1%
$container: 100%
@function gridder($columns)
$t1: $container / $grid
$t2: ($t1 * $columns)
@return $t2 - $margins * 2
.container_#{$grid}
width: $container
margin: 0
overflow: hidden
.grid_2
width: +gridder(2)
Are available the basic arithmetic
operations :
addition +, subtraction -,
multiplication*, division /, modulus %
@function directive always requires a
@return value to return
Convert n to percent : n * 1%
Convert p to number : p * 0.01
Arithmetic operations and a little function
: Control directives & expressions
$size-base: 12px
$font-base: ‘Helvetica’
$color: red
h1
@if $font-base == ‘Helvetica’
font-size: $size-base * 2
line-height: 1em
margin-bottom: 1em
@else if $font-base == arial
color: blue
line-height: 0.5em
@else
font-size: $size-base
line-height: normal
@if , @for and @each with list variables
We can evaluate expressions with the
usual logical operators :
equal sign ==, not equal !=, less than <,
greater than >, less than or equal to
<=, greater than or equal to >=
And also you can concatenate
conditions with boolean operators
and, or, not
// @if ($a == 1) and ($b > 2)
: Control directives & expressions
@for $i from 1 through 3
.item-#{$i}
width: $i * 2px
$icons: home, cart, search
@each $icon in $icons
$name: icon-#{$icon}
$url: url(‘img/#{$name}.png’)
.#{$name}
background: $url
@if , @for and @each with list variables
// for output
.item-1 { width: 2px }
.item-2 { width: 4px }
.item-3 { width: 6px }
// each output
.icon-home {
background: url(‘img/icon-home.png’)}
.icon-cart {
background: url(‘img/icon-cart.png’)}
.icon-search {
background: url(‘img/icon-search.png’)}
csssass
: Sources and Links
SASS_REFERENCE
http://sass-lang.com/documentation/file.SASS_REFERENCE.html
SASSMEISTER
http://sassmeister.com/
BOOTSTRAP SASS
https://github.com/twbs/bootstrap-sass
Thanks !
@romiguelangel
Miguel Ángel Ríos | Frontend Developer

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
Zeeshan Ahmed
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
Bryce Kerley
 

Was ist angesagt? (13)

Document
DocumentDocument
Document
 
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
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
LESS(CSS preprocessor)
LESS(CSS preprocessor)LESS(CSS preprocessor)
LESS(CSS preprocessor)
 
McrFRED 39 | CSS Processors
McrFRED 39 | CSS ProcessorsMcrFRED 39 | CSS Processors
McrFRED 39 | CSS Processors
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction 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"
 
UI Realigning & Refactoring by Jina Bolton
UI Realigning & Refactoring by Jina BoltonUI Realigning & Refactoring by Jina Bolton
UI Realigning & Refactoring by Jina Bolton
 
CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
Css
CssCss
Css
 
Css
CssCss
Css
 
AAVN_Presentation_SASS.pptx
AAVN_Presentation_SASS.pptxAAVN_Presentation_SASS.pptx
AAVN_Presentation_SASS.pptx
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 

Ähnlich wie Sass Essentials

CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
Hock Leng PUAH
 
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
 
LIS3353 SP12 Week 13
LIS3353 SP12 Week 13LIS3353 SP12 Week 13
LIS3353 SP12 Week 13
Amanda Case
 

Ähnlich wie Sass Essentials (20)

CSS3 notes
CSS3 notesCSS3 notes
CSS3 notes
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and Cons
 
Web Typography
Web TypographyWeb Typography
Web Typography
 
Pemrograman Web 2 - CSS
Pemrograman Web 2 - CSSPemrograman Web 2 - CSS
Pemrograman Web 2 - CSS
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Finding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with CompassFinding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with Compass
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
 
Sakai Meet MORPHEUS: Slides
Sakai Meet MORPHEUS: SlidesSakai Meet MORPHEUS: Slides
Sakai Meet MORPHEUS: Slides
 
@Agawish creating a stunning ui with oracle adf faces, using sass
@Agawish   creating a stunning ui with oracle adf faces, using sass@Agawish   creating a stunning ui with oracle adf faces, using sass
@Agawish creating a stunning ui with oracle adf faces, using sass
 
Accessibility and css - Lisa Seeman
Accessibility and css - Lisa SeemanAccessibility and css - Lisa Seeman
Accessibility and css - Lisa Seeman
 
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
 
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
 
Webtech File.docx
Webtech File.docxWebtech File.docx
Webtech File.docx
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
LIS3353 SP12 Week 13
LIS3353 SP12 Week 13LIS3353 SP12 Week 13
LIS3353 SP12 Week 13
 

Kürzlich hochgeladen

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
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 

Kürzlich hochgeladen (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
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
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
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-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 

Sass Essentials

  • 1. SASS ESSENTIALS Sass: Syntactically Awesome Style Sheets @romiguelangel
  • 2. : About me Miguel Ángel Ríos | @romiguelangel Frontend Developer at and
  • 3. : What is SASS ? SASS is a pseudo-language that adds superpowers to your css, allowing use variables, functions, control statements, inheritance, interpolation, etc ..
  • 4. : How can SASS help you ? Scalability Maintenance Increase development speed Apply DRY (Don’t Repeat Yourself) More control over the code Apply Clean Code principles ...
  • 5. : How it say ? SASS or SCSS ? You can type SASS with two syntaxes : body font-family: $font-base background-color: white p, a font-size: $size-base h1, .h1 font-size: $size-base * 1.5 a text-decoration: none &, &:active, &:visited color: black &:hover +transition(color, 0.25s) color: $color-selected SASS Don't use brackets or semicolons .SASS file extension Elements indentation set specification level of your selectors
  • 6. : How it say ? SASS or SCSS ? body { font-family: $font-base; background-color: white; } p, a { font-size: $size-base; } h1, .h1 { font-size: $size-base * 1.5 } a { text-decoration: none; &, &:active, &:visited { color: black; } &:hover { @include transition(color, 0.25s); color: $color-selected; } } SCSS Use brackets and semicolons .SCSS file extension Every valid CSS3 stylesheet is a valid SCSS CSS SCSS You can type SASS with two syntaxes :
  • 7. : but, How can I install it ? Open a terminal and : # Require ruby $ gem install sass # Test $ sass -v Sass 3.3.4 (Maptastic Maple)
  • 8. : All right, how can I convert my css ? $ sass-convert [input] [output] # CSS to SASS $ sass-convert main.css main.sass # CSS to SCSS $ mv main.css main.scss # SCSS to SASS $ sass-convert main.scss main.sass Open a terminal and :
  • 9. : Processing CSS $ sass [--option] [input]:[output] # Create or update main.css once $ sass --update main.sass:main.css # Active watcher and update main.css by each change $ sass --watch main.sass:main.css # Compile all folder files into css folder $ sass --watch .:../css # Output compressed in one line $ sass --watch .:../css --style compressed Leave open a terminal and :
  • 10. : Variables $ Prefixed with $ symbol Can be colors, values, fonts, arithmetic operations, etc .. Can contain more than one item, making a list that can be traveled with a control statement. $font-base: arial, sans-serif $color-base: #333333 $color-selected: #FFA500 $size-base: 12px $size-large: $size-base * 1.5 body font: family: $font-base size: $size-base h1, .h1 font-size: $size-large a color: $color-base &:hover color: $color-selected Store information and reused after
  • 11. : Nesting Keep nesting proportion. e.g. If you indent first with n tabs, you need to use the same tabs for all levels of nesting. You can indent with tabs or spaces, but not both at once. It’s recommended to not exceed the 3 levels of indentation, to avoid high levels of specification in the output file. .product display: inline-block .product-header text-align: center .product-content max-height: 300px .product-footer background-color: #EEE li float: left margin-right: 10px &:last-child margin: 0 N1 N2 N3 Clear hierarchy thanks to indentation
  • 12. : Partials & Imports We can import other style files (partials) to build our output file. There are two partials types : Without underscore e.g. buttons.sass Generates an output file css also included in the parent file. With underscore e.g. _buttons.sass NO generates output file, are only included in the parent file. // inside of main.sass @import _reset.sass @import media.sass Load different modules to make your css _reset main media main media CSS SASS
  • 13. : Mixins To declare can be used both prefixes : = or @mixin Once generated will be included with the @include or + sign followed by the name of the mixin and its arguments Don’t need arguments, you can only generate blocks with styles @mixin border-radius($radius) -webkit-border-radius: $radius -moz-border-radius: $radius border-radius: $radius =clearfix display: inline-block &:after content: "." display: block height: 0 clear: both visibility: hidden * html & height: 1px .block +border-radius(10px) @include clearfix Encapsule styles and use like a function
  • 14. : @Extend and %placeholders Using @extend inherit all the properties of the element we need The %placeholders avoid generating the root element in the output file, reducing our code and making it more semantic It’s not recommended to extend major selectors (h1, ul, li, etc ..), it could generate inheritance loops %button-base display: inline-block text-align: center padding: 5px 10px cursor: pointer border: 1px solid #BBB .button-success @extend %button-base background-color: green .button-remove @extend %button-base background-color: red .button-remove-disabled @extend .button-remove pointer-events: none Inheritance from selectors and classes
  • 15. : Interpolation We will use #{$var} to put a variable inside a string, class, id or to generate a property. // Into elements $color: red .button-#{$color} color: $color // Into strings $sprite: ‘sprite27.png’ .icon-home background: url(‘img/#{$sprite}’) // Into properties $property: border-radius $values: 10px =super-mixin($property, $values) -webkit-#{$property}: $values -moz-#{$property}: $values #{$property}: $values Variables into elements, strings and properties
  • 16. : Operations & Basic functions $grid: 12 // max columns $margins: 1% $container: 100% @function gridder($columns) $t1: $container / $grid $t2: ($t1 * $columns) @return $t2 - $margins * 2 .container_#{$grid} width: $container margin: 0 overflow: hidden .grid_2 width: +gridder(2) Are available the basic arithmetic operations : addition +, subtraction -, multiplication*, division /, modulus % @function directive always requires a @return value to return Convert n to percent : n * 1% Convert p to number : p * 0.01 Arithmetic operations and a little function
  • 17. : Control directives & expressions $size-base: 12px $font-base: ‘Helvetica’ $color: red h1 @if $font-base == ‘Helvetica’ font-size: $size-base * 2 line-height: 1em margin-bottom: 1em @else if $font-base == arial color: blue line-height: 0.5em @else font-size: $size-base line-height: normal @if , @for and @each with list variables We can evaluate expressions with the usual logical operators : equal sign ==, not equal !=, less than <, greater than >, less than or equal to <=, greater than or equal to >= And also you can concatenate conditions with boolean operators and, or, not // @if ($a == 1) and ($b > 2)
  • 18. : Control directives & expressions @for $i from 1 through 3 .item-#{$i} width: $i * 2px $icons: home, cart, search @each $icon in $icons $name: icon-#{$icon} $url: url(‘img/#{$name}.png’) .#{$name} background: $url @if , @for and @each with list variables // for output .item-1 { width: 2px } .item-2 { width: 4px } .item-3 { width: 6px } // each output .icon-home { background: url(‘img/icon-home.png’)} .icon-cart { background: url(‘img/icon-cart.png’)} .icon-search { background: url(‘img/icon-search.png’)} csssass
  • 19. : Sources and Links SASS_REFERENCE http://sass-lang.com/documentation/file.SASS_REFERENCE.html SASSMEISTER http://sassmeister.com/ BOOTSTRAP SASS https://github.com/twbs/bootstrap-sass
  • 20. Thanks ! @romiguelangel Miguel Ángel Ríos | Frontend Developer