SlideShare a Scribd company logo
1 of 74
Download to read offline
Getting Sassy
with CSS
Julie Cameron
@jewlofthelotus
#SassyCSS
bit.ly/getting-sassy
DERP.
I <3 PAIR PROGRAMMING
Syntactically Awesome Stylesheets
NOT an
acronym…
Syntactically Awesome Stylesheets
NOT
SASS
dot com
“If you see something, say something.
Only you can prevent overcapitalization.”
Hampton Catlin, Creator Of Sass
Just don’t be a
#Sasshole
about it. :)
Welcome to the
Sass
community!!
What Is Sass?
1. An extension of CSS
SassScript Language. Fully CSS-compatible syntax.
What Is Sass?
1. An extension of CSS
SassScript Language. Fully CSS-compatible syntax.
2. A CSS preprocessor
SassScript MAGIC CSS
Where Did Sass Come From?
• 2007: Designed by
Hampton Catlin (Haml)
• Developed by Chris
Eppstein (Compass) and
Natalie Weizenbaum
Why Did They Make Sass?
Because vanilla CSS just
wasn’t cutting it any more.
Bert Bos, CSS Co-Inventor
CSS stops short of even more powerful
features […]. That is because these things
give power-users a lot of rope, but less
experienced users will unwittingly hang
themselves; or, more likely, be so scared
that they won’t even touch CSS.
“
What Does Sass Give
Us That CSS Doesn’t?
• Nesting
• Imports
• Variables
• Mixins
• Inheritance
• Functions
• Loops
• AWESOME
What Does Sass Give
Us That CSS Doesn’t?
• Reduced Repetition
• Cleaner Modularity
• Maintainability
• Scalability
• REAL PROGRAMMING!
Setup & Workflow
Sass Installation
Ruby
OS X? Lucky you, it’s preinstalled!
Windows? Try RubyInstaller.
Sass
$ gem install sass
Sass Installation
LibSass (C/C++)
sass-lang.com/libsass
Compiling Sass
Sass CSS
$ sass source.sass output.css
$ sass source_dir output_dir
MAGIC
Sass Is Watching You
$ sass —-watch source.sass:output.css
This is the best thing. Ever.
Gotchya: Colon vs. Space
Two Sass Syntaxes
Sassy CSS .scss
Default; Valid CSS == Valid SCSS
Indented .sass
Original syntax; Haml-esque
The Good Stuff
Or, Why You’ll Never Write Plain Old CSS Again.
NESTING
Nesting
HTML has a clear hierarchy - elements are nested.
We can apply the same concept in Sass.
HTML Sass
Nesting Output
MAGIC
Sass CSS
Nesting Gotchya
Mirroring HTML nesting is
SUPER easy.
MAGIC?
Overly verbose and overly specific.
General Rule:
No more than 2-3 levels deep
Sass
CSS
Nesting The Parent Selector
You can reference parent selector(s) with an &
MAGIC
Sass CSS
Nesting The Parent Selector
The & can follow other selectors, too!
MAGIC
Sass
CSS
Sass
Nesting The Parent Selector
You can also append a suffix to the &!
MAGIC
CSS
Nesting Media Queries
MAGIC
THIS IS FREAKING AWESOME.
Sass CSS
Note: Matching media queries will
not group together in the output.
IMPORTS
AND ORGANIZATION
Imports
CSS @import has always
meant an extra file download.
Sass (application.scss)
Sass modifies @import to
instead include the resource
during compilation, rather
than on the client side.
Imports File Structure
• project_awesome
• sass
• lib
• fontawesome.scss
• base.scss
• grid.scss
• application.scss
• css
Sass
Imports File Structure
• project_awesome
• sass
• lib
• fontawesome.scss
• base.scss
• grid.scss
• application.scss
• css
$ sass sass/application.scss css/application.css
Sass
Imports File Structure
• project_awesome
• sass
• lib
• fontawesome.scss
• base.scss
• grid.scss
• application.scss
• css
$ sass sass/application.scss css/application.css
Sass
• application.css
Imports File Structure
• project_awesome
• sass
• lib
• fontawesome.scss
• base.scss
• grid.scss
• application.scss
$ sass sass/ css/
Imports File Structure
• project_awesome
• sass
• lib
• fontawesome.scss
• base.scss
• grid.scss
• application.scss
$ sass sass/ css/
• project_awesome
• css
• lib
• fontawesome.css
• base.css
• grid.css
• application.css
MAGIC
Import Partials
• project_awesome
• sass
• lib
• _fontawesome.scss
• _base.scss
• _grid.scss
• application.scss
• print.css
$ sass sass/ css/
Import Partials
• project_awesome
• sass
• lib
• _fontawesome.scss
• _base.scss
• _grid.scss
• application.scss
• print.css
$ sass sass/ css/
MAGIC
• project_awesome
• sass
• …
• css
• application.css
• print.css
VARIABLES
Variables
WTF is
#531946?
#30162b?
#095179?
WAT?
Variables
Variables let you
reuse single values.
Sass
Variable Uses
colors
font sizes
font families
font paths
padding
margins
breakpoints
border-radius
pseudo content
shadows
gradients
SELECTORS!
LOGIC!
ALL THE THINGS!!!1!
Variable Data Types
Numbers
Strings
Colors
Lists
Booleans
Null
Maps
Sass
Variable Dynamics
• Mutable.
• Can be
interpolated.
• Have scopes.
Sass
MATH+
COLOR
Math
• + addition
• - subtraction
• * multiplication
• / division
• % modulus
Sass gives us basic math operations.
Sass
SassyCSS
Math Functions
• abs($num) - absolute value
• ceil($num) - round up to closest whole number
• floor($num) - round down to closest whole number
• percentage($num) - convert to percentage
• round($num) - round to closest whole number
• max($list) - maximum list value
• min($list) - minimum list value
Sass comes with a set of math functions.
Color Math
We can even use math to manipulate colors.
Sass
Color Functions
• rgba($hex, $alpha)
• lighten($color, $percent)
• darken($color, $percent)
• saturate($color, $percent)
• desaturate($color, $percent)
• mix($color1, $color2)
• grayscale($color)
• invert($color)
• complement($color)
• AND MANY MORE!
Sass comes with AWESOME color functions.
http://sassme.arc90.com
MIXINS
Mixins
Variables let you reuse single values
Mixins let you reuse blocks of styles
Mixins Use
CSS Sass
Mixins output their contents where they are called.
Mixin Output
Mixin Features
• argument defaults
• multiple arguments
• optional arguments
M
AGIC
CSS
Sass
Mixin Alternative?
Grouped OutputCSS
@EXTEND
INHERITANCE
@extend
Lets you group selectors
and styles together
MAGIC
Sass
CSS
Placeholders
Placeholders can be @extended but will
never compile to the CSS on their own
MAGIC
Sass
CSS
Plus Lots More WIN
Functions
Conditions
extra-light
Each Loops
For Loops
While Loops
Maps
Key-value pairs.
• Multiple assignment in loops.
• Lots of helper methods.
Demo Time
https://github.com/roytomeij/sassconf
Resources
Sass-Lang.com
The Sass Way
Sass For Web Designers
Assembling Sass
SassNews Newsletter
SassConf
SassConf 2013 Videos
SassMeister
Sass Style Guide
#teamSass
Closing Tips
• Take it one step at a time.
• Keep an eye on your output.
• Don’t nest too deeply.
• Mind your @mixins and @media queries.
• Careful with your @extends.
• Modularize all the things.
<3
Thank You!
Getting Sassy
with CSS
#SassyCSS
bit.ly/getting-sassy
Questions?

More Related Content

What's hot

Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
Jeff Byrnes
 
Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...
Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...
Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...
SlideTeam.net
 

What's hot (20)

Sass
SassSass
Sass
 
10 Advanced CSS Techniques (You Wish You Knew More About)
10 Advanced CSS Techniques (You Wish You Knew More About)10 Advanced CSS Techniques (You Wish You Knew More About)
10 Advanced CSS Techniques (You Wish You Knew More About)
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The Cosmetic
 
Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3
 
ECS19 - Chris Kent - List Formatting in Office 365 and SharePoint 2019
ECS19 - Chris Kent - List Formatting in Office 365 and SharePoint 2019ECS19 - Chris Kent - List Formatting in Office 365 and SharePoint 2019
ECS19 - Chris Kent - List Formatting in Office 365 and SharePoint 2019
 
Web 102 INtro to CSS
Web 102  INtro to CSSWeb 102  INtro to CSS
Web 102 INtro to CSS
 
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
Sara Soueidan: Styling and Animating Scalable Vector Graphics with CSS [CSSCo...
 
Learn svg
Learn svgLearn svg
Learn svg
 
Intro to HTML + CSS
Intro to HTML + CSSIntro to HTML + CSS
Intro to HTML + CSS
 
CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship Course
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to Respond
 
Mobile and Responsive Design with Sass
Mobile and Responsive Design with SassMobile and Responsive Design with Sass
Mobile and Responsive Design with Sass
 
Css 3
Css 3Css 3
Css 3
 
Css 3
Css 3Css 3
Css 3
 
Getting SASSy with front end development
Getting SASSy with front end developmentGetting SASSy with front end development
Getting SASSy with front end development
 
Castro Chapter 7
Castro Chapter 7Castro Chapter 7
Castro Chapter 7
 
Colors In CSS3
Colors In CSS3Colors In CSS3
Colors In CSS3
 
Sane CSS - A modern approach to CSS
Sane CSS - A modern approach to CSSSane CSS - A modern approach to CSS
Sane CSS - A modern approach to CSS
 
Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
 
Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...
Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...
Cycle circular round jigsaw maze piece puzzle with center 4 powerpoint ppt te...
 

Viewers also liked

Viewers also liked (9)

So You Think You Know Podcasting
So You Think You Know  PodcastingSo You Think You Know  Podcasting
So You Think You Know Podcasting
 
Lessons learned from The Innovation Hub
Lessons learned from The Innovation HubLessons learned from The Innovation Hub
Lessons learned from The Innovation Hub
 
Professor John Higgins
Professor John Higgins Professor John Higgins
Professor John Higgins
 
Thinking Fast and Slow
Thinking Fast and SlowThinking Fast and Slow
Thinking Fast and Slow
 
Product Management 90 Day Plan
Product Management 90 Day PlanProduct Management 90 Day Plan
Product Management 90 Day Plan
 
30 60 90 Day Plan Format
30 60 90 Day Plan Format30 60 90 Day Plan Format
30 60 90 Day Plan Format
 
BVU Technology and Communications Summit Plenary Powerpoint
BVU Technology and Communications Summit Plenary PowerpointBVU Technology and Communications Summit Plenary Powerpoint
BVU Technology and Communications Summit Plenary Powerpoint
 
The Changing Role of IT Staff
The Changing Role of IT StaffThe Changing Role of IT Staff
The Changing Role of IT Staff
 
LeadingAST.com - Sample 90 day leadership plan
LeadingAST.com - Sample 90 day leadership planLeadingAST.com - Sample 90 day leadership plan
LeadingAST.com - Sample 90 day leadership plan
 

Similar to Getting Sassy with CSS

The sass way - Yatendra Bhardwaj
The sass way - Yatendra BhardwajThe sass way - Yatendra Bhardwaj
The sass way - Yatendra Bhardwaj
Yatendra Bhardwaj
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
Itai Koren
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
Zeeshan Ahmed
 

Similar to Getting Sassy with CSS (20)

Sass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by ShafeeqSass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by Shafeeq
 
DrupalCamp Chattanooga - September 2014 - Sass 101
DrupalCamp Chattanooga - September 2014 - Sass 101DrupalCamp Chattanooga - September 2014 - Sass 101
DrupalCamp Chattanooga - September 2014 - Sass 101
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress Developers
 
Sass that CSS
Sass that CSSSass that CSS
Sass that CSS
 
Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 
The sass way - Yatendra Bhardwaj
The sass way - Yatendra BhardwajThe sass way - Yatendra Bhardwaj
The sass way - Yatendra Bhardwaj
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Bliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS Introduction
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
European SharePoint Webinar - Make SharePoint Sassy
European SharePoint Webinar - Make SharePoint SassyEuropean SharePoint Webinar - Make SharePoint Sassy
European SharePoint Webinar - Make SharePoint Sassy
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Atlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass Topics
Atlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass TopicsAtlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass Topics
Atlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass Topics
 
Sass
SassSass
Sass
 
CSS3
CSS3CSS3
CSS3
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
SASS Preprocessor
SASS PreprocessorSASS Preprocessor
SASS Preprocessor
 
Make your CSS beautiful again
Make your CSS beautiful againMake your CSS beautiful again
Make your CSS beautiful again
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction 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?
 

More from Julie Cameron

More from Julie Cameron (7)

Growing a Thriving and Engaged Remote Team
Growing a Thriving and Engaged Remote TeamGrowing a Thriving and Engaged Remote Team
Growing a Thriving and Engaged Remote Team
 
Yoga & mindfulness for people who stare at computers all day
Yoga & mindfulness for people who stare at computers all dayYoga & mindfulness for people who stare at computers all day
Yoga & mindfulness for people who stare at computers all day
 
Lifesaving, Timesaving, Sanity-saving HOTKEYS!
Lifesaving, Timesaving, Sanity-saving HOTKEYS!Lifesaving, Timesaving, Sanity-saving HOTKEYS!
Lifesaving, Timesaving, Sanity-saving HOTKEYS!
 
On Entering Open Source
On Entering Open SourceOn Entering Open Source
On Entering Open Source
 
Decoupling the Front-end with Modular CSS
Decoupling the Front-end with Modular CSSDecoupling the Front-end with Modular CSS
Decoupling the Front-end with Modular CSS
 
Intro to OOCSS Workshop
Intro to OOCSS WorkshopIntro to OOCSS Workshop
Intro to OOCSS Workshop
 
OOCSS Lightening Talk
OOCSS Lightening TalkOOCSS Lightening Talk
OOCSS Lightening Talk
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Getting Sassy with CSS