SlideShare a Scribd company logo
Making CSS fun again :)
About
○ Front end developer at Conrad Caine
○ Analysis and development of systems at SENAC
This is my first presentation and everything can be boring...
                      so let's drink beer!
I will talk about
○ CSS weaknesses
○ Syntax
○ Features
○ Techniques
○ ...
CSS WEAKNESSES
What's wrong with CSS?
○ No variables
○ Prefixes
○ Lack of abstraction
○ Hard to maintain (mainly in big css files)
THE SOLUTION
CSS Preprocessors
○ Sass
○ Less
○ Stylus




            They are the most popular.
WHAT ARE CSS
PREPROCESSORS?
What are CSS Preprocessor?
"CSS preprocessors take code written in the preprocessed
language and then convert that code into the same old css
we’ve been writing for years."
STARTING WITH SASS
About
○ Syntactically Awesome StyleSheets
○ Sass makes CSS fun again
○ Sass get installed as Ruby gem, then you need to have
   Ruby on your machine.
Installing
gem install sass
The Process
○ Create a .scss file
○ Watch this .scss
○ Sass will create your .css
○ Be happy!
Watching a .scss file
sass --watch dev.scss:style.css
Output style
Sass allows you to choose between four different output
styles using the --style command-line flag.


sass --watch dev.scss:style.css   --style nested
sass --watch dev.scss:style.css   --style expanded
sass --watch dev.scss:style.css   --style compact
sass --watch dev.scss:style.css   --style compressed
VARIABLES
How can we do this today?
Variables
/* dev.scss */        /* output */
$width: 100px;        .side {
$color: #00214D;        width: 100px;
$size: 16px;          }

.side {               .bar {
  width: $width;        width: 100px;
}                       font-size: 16px;
                        color: #00214D;
.bar {                }
  width: $width;
  font-size: $size;
  color: $color;
}
Math operations
/* dev.scss */              /* output */
$width: 600px;              .nav li {
$length: 3;                   width: 200px;
                            }
.nav li {
  width: $width / $length
}
Color functions
/* dev.scss */                     /* output */
$color: #ce4dd6;                   .nav a {
                                     color: #e5a0e9;
                                   }
.nav a {
                                   .nav a:hover {
  color: lighten($color, 20%);       color: #d976e0;
  &:hover {                        }
    color: lighten($color, 10%);
  }
}
NESTING
We are accustomed to do this:
/* primate.css */
.nav li {
  list-style:none;
  float:left;
}

.nav li a {
  display:block;
  padding:5px;
}
Now we can do this:
/* dev.scss */          /* output */
.nav {                  .nav li {
  li {                    list-style: none;
                          float: left;
    list-style:none;
                        }
    float:left;
    a {                 .nav li a {
       display:block;     display: block;
       color:blue;        color: blue;
    }                   }
  }
}
Parent Reference
/* dev.scss */          /* output */
.nav {                  .nav li {
  li {                    list-style: none;
                          float: left;
    list-style:none;
                        }
    float:left;
    a {                 .nav li a {
       display:block;     display: block;
       color:blue;        color: blue;
       &:hover {        }
         color:red;
                        .nav li a:hover {
       }
                          display: block;
    }                     color: red;
  }                     }
}
MIXINS
Mixins
/* primate.css */
.nav li a {
  padding: 5px;
  border: 1px solid red;
  -moz-border-radius: 10px;
  -webkit-border-radius:
10px;
  border-radius: 10px;
}
Mixins
/* dev.scss */               /* output */
@mixin borderRadius {        .nav li a {
 -moz-border-radius: 10px;     padding: 5px;
                               border: 1px solid red;
 -webkit-border-radius:
10px;                          -moz-border-radius: 10px;
                               -webkit-border-radius:
 border-radius: 10px;        10px;
}                              border-radius: 10px;
                             }
.nav li a {
 padding: 5px;
 border: 1px solid red;
 @include borderRadius;
}
Arguments
/* dev.scss */            /* output */
@mixin title($size) {     article h2 {
  font: {                   font-family: arial;
                            font-size: 40px;
    family: arial;
                            font-weight: bold;
    size: $size;          }
    weight: bold;
  }
}

article h2 {
  @include title(40px);
}
INHERITANCE
Inheritance
/* dev.scss */              /* output */
.nav {                      .nav, .category {
   background: #CCC;          background: #CCC;
                              border: 1px solid red;
   border: 1px solid red;
                            }
}

.category {
   @extend .nav;
}
INTERPOLATION
Interpolation
/* dev.scss */            /* output */
$name: box;               p.box {
$attr: border;              border-color: blue;
                          }
p.#{$name} {
  #{$attr}-color: blue;
}
@import
@import




     core.css   fonts.css   reset.css   footer.css
@import
/* dev.scss */           /* output */
@import "reset.scss";
@import "fonts.scss";    /* reset */
@import "footer.scss";   html {}

                         /* fonts */
                         @font-face {}

                         /* footer */
                         footer {}
Control Directives
@if
/* dev.scss */                /* output */
$type: 'games';
                              p {
p {                             color: blue;
  @if $type == sports {       }
    color: green;
  }
  @else if $type == games {
    color: blue;
  }
  @else {
    color: red;
  }
}
@for
/* dev.scss */               /* output */
@for $i from 1 through 3 {   .item-1 {
  .item-#{$i} {                font-size: 12px;
                             }
    font-size: 12px * $i;
  }                          .item-2 {
}                              font-size: 24px;
                             }

                             .item-3 {
                               font-size: 36px;
                             }
@each
/* dev.scss */              /* output */
@each $type in a, b, c {    .a-icon {
  .#{$type}-icon {            background-image: url
                            ("/images/a.png");
    background-image: url
('/images/#{$type}.png');   }
  }                         .b-icon {
}                             background-image: url
                            ("/images/b.png");
                            }

                            .c-icon {
                              background-image: url
                            ("/images/c.png");
                            }
@while
/* dev.scss */                 /* output */
$i: 6;                         .item-6 {
@while $i > 0 {                  width: 12px;
                               }
  .item-#{$i} { width: 2px *
$i; }
                               .item-4 {
  $i: $i - 2;                    width: 8px;
}                              }

                               .item-2 {
                                 width: 4px;
                               }
Thank you!
○ gabrielneutzling@gmail.com
○ facebook.com/gneutzling
○ @gneutzling

More Related Content

KEY
FCIP SASS Talk
PDF
Krueger Library Custom CSS for LibGuides
PPTX
Oocss & progressive css3 selectors
PDF
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
PDF
HTML5 and CSS3 Refresher
PPTX
Oh, you’re the NY times guy
KEY
Using Sass - Building on CSS
PPTX
CSS: A Slippery Slope to the Backend
FCIP SASS Talk
Krueger Library Custom CSS for LibGuides
Oocss & progressive css3 selectors
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
HTML5 and CSS3 Refresher
Oh, you’re the NY times guy
Using Sass - Building on CSS
CSS: A Slippery Slope to the Backend

What's hot (19)

KEY
DBIx::Skinnyと仲間たち
PDF
Make your own wp cli command in 10min
PDF
Theming Ext JS 4
PDF
Rapid Prototyping
PDF
CGI.pm - 3ло?!
PDF
PhoneGap: Local Storage
PPTX
SQL Injection Part 2
PDF
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)
PDF
CSS3 Refresher
PDF
Jina Bolton
PDF
JSON Schema in Web Frontend #insideFE
ODP
Google Cloud Challenge - PHP - DevFest GDG-Cairo
PDF
CSSプリプロセッサの取扱説明書
PPTX
Auto tools
PDF
Shortcodes In-Depth
PDF
R57php 1231677414471772-2
TXT
Bouncingballs sh
PDF
Mojolicious: what works and what doesn't
PPTX
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
DBIx::Skinnyと仲間たち
Make your own wp cli command in 10min
Theming Ext JS 4
Rapid Prototyping
CGI.pm - 3ло?!
PhoneGap: Local Storage
SQL Injection Part 2
Sass 基礎教學 - 高雄前端社群(CSS 讀書會)
CSS3 Refresher
Jina Bolton
JSON Schema in Web Frontend #insideFE
Google Cloud Challenge - PHP - DevFest GDG-Cairo
CSSプリプロセッサの取扱説明書
Auto tools
Shortcodes In-Depth
R57php 1231677414471772-2
Bouncingballs sh
Mojolicious: what works and what doesn't
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Ad

Similar to Sass - Making CSS fun again. (20)

PDF
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
PDF
CSS Extenders
KEY
Wrangling the CSS Beast with Sass
PDF
Work and play with SASS & Compass
KEY
Sass&compass
PDF
Theming and Sass
PPTX
Css frameworks
PDF
Sencha Touch
PPTX
Software programming tools for creating/managing CSS files
PDF
Preprocessor presentation
PDF
Curso CSS3 com Sass e Compass - Aula 01 - Introducão
PDF
Accelerated Stylesheets
KEY
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
PDF
Sass and Compass - Getting Started
PDF
LessCSS Presentation @ April 2015 GTALUG Meeting
KEY
Finding a Better Way to CSS: Navigating Sass with Compass
PDF
Doing more with LESS
PDF
Getting Started with Sass & Compass
PDF
Ext js saas&compass
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
CSS Extenders
Wrangling the CSS Beast with Sass
Work and play with SASS & Compass
Sass&compass
Theming and Sass
Css frameworks
Sencha Touch
Software programming tools for creating/managing CSS files
Preprocessor presentation
Curso CSS3 com Sass e Compass - Aula 01 - Introducão
Accelerated Stylesheets
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Sass and Compass - Getting Started
LessCSS Presentation @ April 2015 GTALUG Meeting
Finding a Better Way to CSS: Navigating Sass with Compass
Doing more with LESS
Getting Started with Sass & Compass
Ext js saas&compass
Ad

Recently uploaded (20)

PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Approach and Philosophy of On baking technology
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Big Data Technologies - Introduction.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Network Security Unit 5.pdf for BCA BBA.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Spectral efficient network and resource selection model in 5G networks
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
sap open course for s4hana steps from ECC to s4
Approach and Philosophy of On baking technology
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Big Data Technologies - Introduction.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Building Integrated photovoltaic BIPV_UPV.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx
Per capita expenditure prediction using model stacking based on satellite ima...
Reach Out and Touch Someone: Haptics and Empathic Computing
Dropbox Q2 2025 Financial Results & Investor Presentation
Programs and apps: productivity, graphics, security and other tools
Network Security Unit 5.pdf for BCA BBA.

Sass - Making CSS fun again.

  • 1. Making CSS fun again :)
  • 2. About ○ Front end developer at Conrad Caine ○ Analysis and development of systems at SENAC
  • 3. This is my first presentation and everything can be boring... so let's drink beer!
  • 4. I will talk about ○ CSS weaknesses ○ Syntax ○ Features ○ Techniques ○ ...
  • 6. What's wrong with CSS? ○ No variables ○ Prefixes ○ Lack of abstraction ○ Hard to maintain (mainly in big css files)
  • 8. CSS Preprocessors ○ Sass ○ Less ○ Stylus They are the most popular.
  • 10. What are CSS Preprocessor? "CSS preprocessors take code written in the preprocessed language and then convert that code into the same old css we’ve been writing for years."
  • 12. About ○ Syntactically Awesome StyleSheets ○ Sass makes CSS fun again ○ Sass get installed as Ruby gem, then you need to have Ruby on your machine.
  • 14. The Process ○ Create a .scss file ○ Watch this .scss ○ Sass will create your .css ○ Be happy!
  • 15. Watching a .scss file sass --watch dev.scss:style.css
  • 16. Output style Sass allows you to choose between four different output styles using the --style command-line flag. sass --watch dev.scss:style.css --style nested sass --watch dev.scss:style.css --style expanded sass --watch dev.scss:style.css --style compact sass --watch dev.scss:style.css --style compressed
  • 18. How can we do this today?
  • 19. Variables /* dev.scss */ /* output */ $width: 100px; .side { $color: #00214D; width: 100px; $size: 16px; } .side { .bar { width: $width; width: 100px; } font-size: 16px; color: #00214D; .bar { } width: $width; font-size: $size; color: $color; }
  • 20. Math operations /* dev.scss */ /* output */ $width: 600px; .nav li { $length: 3; width: 200px; } .nav li { width: $width / $length }
  • 21. Color functions /* dev.scss */ /* output */ $color: #ce4dd6; .nav a { color: #e5a0e9; } .nav a { .nav a:hover { color: lighten($color, 20%); color: #d976e0; &:hover { } color: lighten($color, 10%); } }
  • 23. We are accustomed to do this: /* primate.css */ .nav li { list-style:none; float:left; } .nav li a { display:block; padding:5px; }
  • 24. Now we can do this: /* dev.scss */ /* output */ .nav { .nav li { li { list-style: none; float: left; list-style:none; } float:left; a { .nav li a { display:block; display: block; color:blue; color: blue; } } } }
  • 25. Parent Reference /* dev.scss */ /* output */ .nav { .nav li { li { list-style: none; float: left; list-style:none; } float:left; a { .nav li a { display:block; display: block; color:blue; color: blue; &:hover { } color:red; .nav li a:hover { } display: block; } color: red; } } }
  • 27. Mixins /* primate.css */ .nav li a { padding: 5px; border: 1px solid red; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; }
  • 28. Mixins /* dev.scss */ /* output */ @mixin borderRadius { .nav li a { -moz-border-radius: 10px; padding: 5px; border: 1px solid red; -webkit-border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: border-radius: 10px; 10px; } border-radius: 10px; } .nav li a { padding: 5px; border: 1px solid red; @include borderRadius; }
  • 29. Arguments /* dev.scss */ /* output */ @mixin title($size) { article h2 { font: { font-family: arial; font-size: 40px; family: arial; font-weight: bold; size: $size; } weight: bold; } } article h2 { @include title(40px); }
  • 31. Inheritance /* dev.scss */ /* output */ .nav { .nav, .category { background: #CCC; background: #CCC; border: 1px solid red; border: 1px solid red; } } .category { @extend .nav; }
  • 33. Interpolation /* dev.scss */ /* output */ $name: box; p.box { $attr: border; border-color: blue; } p.#{$name} { #{$attr}-color: blue; }
  • 35. @import core.css fonts.css reset.css footer.css
  • 36. @import /* dev.scss */ /* output */ @import "reset.scss"; @import "fonts.scss"; /* reset */ @import "footer.scss"; html {} /* fonts */ @font-face {} /* footer */ footer {}
  • 38. @if /* dev.scss */ /* output */ $type: 'games'; p { p { color: blue; @if $type == sports { } color: green; } @else if $type == games { color: blue; } @else { color: red; } }
  • 39. @for /* dev.scss */ /* output */ @for $i from 1 through 3 { .item-1 { .item-#{$i} { font-size: 12px; } font-size: 12px * $i; } .item-2 { } font-size: 24px; } .item-3 { font-size: 36px; }
  • 40. @each /* dev.scss */ /* output */ @each $type in a, b, c { .a-icon { .#{$type}-icon { background-image: url ("/images/a.png"); background-image: url ('/images/#{$type}.png'); } } .b-icon { } background-image: url ("/images/b.png"); } .c-icon { background-image: url ("/images/c.png"); }
  • 41. @while /* dev.scss */ /* output */ $i: 6; .item-6 { @while $i > 0 { width: 12px; } .item-#{$i} { width: 2px * $i; } .item-4 { $i: $i - 2; width: 8px; } } .item-2 { width: 4px; }
  • 42. Thank you! ○ gabrielneutzling@gmail.com ○ facebook.com/gneutzling ○ @gneutzling