SlideShare a Scribd company logo
CSS Preprocesser
    Madness
LESS/SCSS/Compass/Bootstrap
About Us
Mario Noble
Charles Mata
Why Madness?
   Because you may become crazy for it.
                 Or over it.
Or maybe just watching this "Powerpoint" will
             drive you insane.
Preprocessors
AKA - The "People's Patch"
Our alternative to the cross browser wars.
At least for the time being...
Learn CSS and good practices first
Preprocessors are not a replacement for good
coding, planning and design.
What is preprocessing?
Preprocessing is essentially creating the
equivalent of a Photoshop file or a suped up
mailing template for your css.

It gives you added umph to your work.

Sometimes making it easier.
Occasionally it might be overkill.
Why do it?
Do you like to type the same thing over and over?
Do you enjoy trying to hunt down a tiny bit of code
somewhere in thousands of lines of code and then using
find and replace hoping it'll work?

No?

Use preprocessing.
Most of all - DRY practices
    Don't Repeat Yourself
Other reasons
● CSS 3 browser prefixes
● Responsive design
● Other people are using it, so you want to
  have a clue.
● Efficiency
● Better organization
● Faster sites and better SEO
Disadvantages
●   Learning curve
●   Team Maintenance
●   Yet another layer
●   Code bloat
●   Selectoritis
Methods and Approaches
●   SASS/SCSS
●   LESS
●   Stylus
●   cleverCSS
●   cssCrush
●   prefixer (http://prefixr.com/)
●   force browser to interpret PHP as CSS
We're going over the two most
popular preprocessors tonight
          LESS and SASS/SCSS




   We'll be glossing over some stuff in the interest of time and clarity
Which is best?
Let's go over what they share
Each of them now share most of each others
capabilities with some minor differences in
syntax.

The following examples are from Chris
Eppstein's gits on: https://gist.github.
com/674726

Thanks Chris!
Variables (placeholders)
Sass             | Less
-----------------+-----------------
$color: red;     | @color: red;
div {            | div {
  color: $color; |   color: @color;
}                | }
              Becomes
      div { color: #ff0000; }
Nesting (outlining)
Sass                | Less
-------------------+-----------------
p {                 | p {
  a {               |     a {
     color: red;    |       color: red;
     &:hover {      |       &:hover {
       color: blue; |         color: blue; }
  }                     }
}                     }

                            Becomes
                       p a {color: red;}
                       p a:hover {color: blue;}
Mixins (mini-templates)
Sass                              | Less
----------------------------------+----------------------------------
@mixin bordered {                 | .bordered {
  border-top: dotted 1px black;   |   border-top: dotted 1px black;
  border-bottom: solid 2px black; |   border-bottom: solid 2px black;
}                                 | }
                                  |
#menu a {                         | #menu a {
  @include bordered;              |   .bordered;
}                                 | }
                     Becomes
                    .bordered {
                      border-top: dotted 1px black;
                      border-bottom: solid 2px black;
                    }
                    #menu a {
                      border-top: dotted 1px black;
                      border-bottom: solid 2px black;
                    }
Mixins with arguments
 (adverbs/adjectives)
Sass                              | Less
----------------------------------+----------------------------------
@mixin bordered($width: 2px) {    | .bordered(@width: 2px) {
  border: $width solid black;     |   border: @width solid black;
}                                 | }
                                  |
#menu a {                         | #menu a {
  @include bordered(4px);         |   .bordered(4px);
}                                 | }


Becomes
#menu a {
  border: 4px solid #000000;
}
Numbers

Sass:                        Less:

1cm * 1em => 1 cm * em       1cm * 1em => Error
2in * 3in => 6 in * in       2in * 3in => 6in
(1cm / 1em) * 4em => 4cm     (1cm / 1em) * 4em
2in + 3cm + 2pc => 3.514in   => Error
3in / 2in => 1.5             2in + 3cm + 2pc =>
                             Error
                             3in / 2in => 1.5in
Imports (Get that there file!)
@import "somefile.less";
@import "somefile";

@import "somefile.scss";
@import "somefile";

@import "somedirectory/somefile.scss";
Interpolation (stick it in there)
SCSS style
                                             LESS style

/* style.scss */                             @base-url: "http://assets.fnord.com";

$side: top;                                  background-image: url("@{base-url}
                                             /images/bg.png");
$radius: 10px;

                                                Becomes:
.rounded- {
  border-#{$side}-radius: $radius;              background-image: url("http://assets.fnord.
                                                com/images/bg.png");.someclass {
  -moz-border-radius-#{$side}: $radius;           color: #333;
  -webkit-border-#{$side}-radius: $radius;      }

}
Escaping (take it literally)
LESS
.class {
  filter: ~"ms:alwaysHasItsOwnSyntax.For.
Stuff()";
}
SASS
.class {
  filter: #{"'ms:alwaysHasItsOwnSyntax.For.
Stuff()'"};
}



Becomes:
.class {filter: ms:alwaysHasItsOwnSyntax.For.Stuff();}
Comments
Both LESS and SCSS use the same comment
structure.

// is a note in the authoring file

/* some note */ is published to the compiled file.
@media query tweaking
LESS (for SASS/SCSS replace @ with $ for
                                                  Becomes:
variables)
                                                  .profile-pic {
@break-small: 320px;                                float: left;
@break-large: 1200px;                               width: 250px;
                                                  }
                                                  @media screen and (max-width:
.profile-pic {                                    320px) {
  float: left;                                      .profile-pic {
  width: 250px;                                       width: 100px;
                                                      float: none;
  @media screen and (max-width: @break-small) {     }
    width: 100px;                                 }
    float: none;                                  @media screen and (min-width:
                                                  1200px) {
  }
                                                    .profile-pic {
  @media screen and (min-width: @break-large) {       float: right;
    float: right;                                   }
  }                                               }
}
Differences
As with anything, there are advantages and
disadvantages of going with various options.

LESS and SASS are no different.

Or rather they are in some ways...
Extra features of SASS/SCSS
● Can properly "extend" other classes.
● True if, for, while and each control directives
  (Logic)
● Global scoping of variables
● Compass (sprites)
● Origin line reporting
● Good Rails integration
● Various output styles
● Real functions that return values
Extra features of LESS
● Namespacing
● Guards and Pattern Matching
● Easy compile "on the fly" with a single
  JavaScript file.
● Variables as constants
● Twitter Bootstrap
● Usual scope practices
● JavaScript evaluation
To compile locally or on the server?
Considerations:

Performance
Coordination
Caching
Server install
Let's demo some Bootstrap n' Stuff!

        Go Charles go!
Preprocessor presentation
Hands on part!
Let's do LESS first

Get the example material or use your own
http://files.meetup.com/1962521/basicHtmlCss.zip

Get the basic js
http://lesscss.org - bonus points - download twitter bootstrap

Get a complier
Mac OSX http://incident57.com/less/
Windows http://winless.org/
Linux/Mac/PC http://wearekiss.com/simpless

Get an editor or download the code hinters
http://www.sublimetext.com/
Already have the LESS stuff?
To install SASS/SCSS

Go here: http://sass-lang.com/tutorial.html
Download the Windows Installer if you're on Windows.
http://rubyinstaller.org/
After that, go to http://compass-style.org/install/
Follow instructions to install both SASS and Compass

Download either Scout
http://mhs.github.com/scout-app/
Compass app is good too. Just paid.

Configure your editor
I recommend SublimeText along with the Package Installer to install
SCSS/LESS code hinting.
"Converting" your existing CSS
Really just nests it.

LEAST
http://toki-woki.net/p/least/

SASS
# Convert Sass to SCSS
$ sass-convert style.css style.scss
LESS useful tools if using the js to
compile.
After you put this into your files:
<link rel="stylesheet/less" type="text/css" href="
styles.less">
<script src="less.js" type="text/javascript"
></script>
Put this after your file name in the url:
#!watch
Chrome users: --allow-file-access-from-files in
shortcut or use a local server
mac : terminal ; open /Applications/Google
Chrome.app --args --allow-file-access-from-files
Compiling
You can use tools or the command line.

SCSS users may need to delve into their
config.rb file or just use the tools.

LESS users might just want to use the tools to
setup publish paths.
Let's have fun with
     variables
 @myvariable or $myvariable
Comments
 // and /* */
Mixins
     @mixin mymixin { }
    @include mymixin { }
       .somemixin { }
.anotherclass { .somemixin }
Mixins with parameters
    @mixin mymixin($hello);
    @include mymixin(10px);

      .somemixin(@hello)
       .somemixin (10px);
Numbers
width: $navbar-width/$items - 10px;

      color: @base-color * 3;
Interpolation
border-#{$side}-radius: $radius;

border-@{side}-radius: $radius;
Gotchas
LESS

Keep your import structure flat.

SCSS

Watch out for imports with .less or not.
Congratz!!!!
You has mad skillz nowz!
Q&A

More Related Content

What's hot (20)

CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
Lucien Lee
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
Idan Gazit
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Claudina Sarahe
 
LESS(CSS preprocessor)
LESS(CSS preprocessor)LESS(CSS preprocessor)
LESS(CSS preprocessor)
VIPIN KUMAR
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
Wynn Netherland
 
Less vs sass
Less vs sassLess vs sass
Less vs sass
Aya Edamoto
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With Sass
Thomas Reynolds
 
Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]
Matt Puchlerz
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
Jon Dean
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
Zeeshan Ahmed
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
edgincvg
 
DRY cross-browser CSS with SASS
DRY cross-browser CSS with SASSDRY cross-browser CSS with SASS
DRY cross-browser CSS with SASS
Wes Oldenbeuving
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
mirahman
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
Knoldus Inc.
 
LESS CSS Pre-processor
LESS CSS Pre-processorLESS CSS Pre-processor
LESS CSS Pre-processor
Kannika Kong
 
CSS3
CSS3CSS3
CSS3
Chathuranga Jayanath
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
jsmith92
 
Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 Minutes
Patrick Crowley
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nl
Hans Kuijpers
 
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
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
Lucien Lee
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Claudina Sarahe
 
LESS(CSS preprocessor)
LESS(CSS preprocessor)LESS(CSS preprocessor)
LESS(CSS preprocessor)
VIPIN KUMAR
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With Sass
Thomas Reynolds
 
Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]
Matt Puchlerz
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
Jon Dean
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
Zeeshan Ahmed
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
edgincvg
 
DRY cross-browser CSS with SASS
DRY cross-browser CSS with SASSDRY cross-browser CSS with SASS
DRY cross-browser CSS with SASS
Wes Oldenbeuving
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
mirahman
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
Knoldus Inc.
 
LESS CSS Pre-processor
LESS CSS Pre-processorLESS CSS Pre-processor
LESS CSS Pre-processor
Kannika Kong
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
jsmith92
 
Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 Minutes
Patrick Crowley
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nl
Hans Kuijpers
 
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
 

Viewers also liked (14)

Cms pres
Cms presCms pres
Cms pres
Mario Noble
 
Turbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & CompassTurbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & Compass
Almog Baku
 
Front End Badassery with Sass
Front End Badassery with SassFront End Badassery with Sass
Front End Badassery with Sass
jessabean
 
Stylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSSStylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSS
sforst
 
Frontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & CompassFrontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & Compass
Andreas Dantz
 
Performance front end language
Performance front end languagePerformance front end language
Performance front end language
Wei-Yi Chiu
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
Rob Davarnia
 
老成的Sass&Compass
老成的Sass&Compass老成的Sass&Compass
老成的Sass&Compass
智遠 成
 
Sass(SCSS)について
Sass(SCSS)についてSass(SCSS)について
Sass(SCSS)について
Kazufumi Miyamoto
 
Save time by using SASS/SCSS
Save time by using SASS/SCSSSave time by using SASS/SCSS
Save time by using SASS/SCSS
Berit Hlubek
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quick
Billy Shih
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshop
Shaho Toofani
 
Horario de clases segundo grado
Horario de clases segundo gradoHorario de clases segundo grado
Horario de clases segundo grado
Everardo Diaz Diaz
 
Sass
SassSass
Sass
Tayseer_Emam
 
Turbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & CompassTurbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & Compass
Almog Baku
 
Front End Badassery with Sass
Front End Badassery with SassFront End Badassery with Sass
Front End Badassery with Sass
jessabean
 
Stylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSSStylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSS
sforst
 
Frontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & CompassFrontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & Compass
Andreas Dantz
 
Performance front end language
Performance front end languagePerformance front end language
Performance front end language
Wei-Yi Chiu
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
Rob Davarnia
 
老成的Sass&Compass
老成的Sass&Compass老成的Sass&Compass
老成的Sass&Compass
智遠 成
 
Save time by using SASS/SCSS
Save time by using SASS/SCSSSave time by using SASS/SCSS
Save time by using SASS/SCSS
Berit Hlubek
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quick
Billy Shih
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshop
Shaho Toofani
 
Horario de clases segundo grado
Horario de clases segundo gradoHorario de clases segundo grado
Horario de clases segundo grado
Everardo Diaz Diaz
 

Similar to Preprocessor presentation (20)

Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
emrox
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
Katsunori Tanaka
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
Sven Wolfermann
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
drywallbmb
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
Marco Pinheiro
 
Less css
Less cssLess css
Less css
Bill Chea
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
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-compass
c l
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 
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
Sanjoy Kr. Paul
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
Even Wu
 
PostCss
PostCssPostCss
PostCss
LearningTech
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie Dust
Kyle Adams
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Adam Darowski
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sass
Huiyi Yan
 
Sass compass
Sass compassSass compass
Sass compass
Nick Cooley
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
Andreas Dantz
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
Rob Friesel
 
Less & Sass
Less & SassLess & Sass
Less & Sass
Михаил Петров
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
Visual Engineering
 
Pacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSPacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASS
Steve Krueger
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
emrox
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
Katsunori Tanaka
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
Sven Wolfermann
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
drywallbmb
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
Marco Pinheiro
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
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-compass
c l
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 
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
Sanjoy Kr. Paul
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
Even Wu
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie Dust
Kyle Adams
 
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Sassive Aggressive: Using Sass to Make Your Life Easier (Refresh Boston Version)
Adam Darowski
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sass
Huiyi Yan
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
Andreas Dantz
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
Rob Friesel
 
Pacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSPacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASS
Steve Krueger
 

More from Mario Noble (8)

UI Animation principles and practice with GSAP
UI Animation principles and practice with GSAPUI Animation principles and practice with GSAP
UI Animation principles and practice with GSAP
Mario Noble
 
Fun with css frameworks
Fun with css frameworksFun with css frameworks
Fun with css frameworks
Mario Noble
 
Styling on steroids
Styling on steroidsStyling on steroids
Styling on steroids
Mario Noble
 
Testing html5 meetup slideshare
Testing html5 meetup slideshareTesting html5 meetup slideshare
Testing html5 meetup slideshare
Mario Noble
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty gritty
Mario Noble
 
Git presentation
Git presentationGit presentation
Git presentation
Mario Noble
 
Responsive design presentation
Responsive design presentationResponsive design presentation
Responsive design presentation
Mario Noble
 
Html5 css3pres
Html5 css3presHtml5 css3pres
Html5 css3pres
Mario Noble
 
UI Animation principles and practice with GSAP
UI Animation principles and practice with GSAPUI Animation principles and practice with GSAP
UI Animation principles and practice with GSAP
Mario Noble
 
Fun with css frameworks
Fun with css frameworksFun with css frameworks
Fun with css frameworks
Mario Noble
 
Styling on steroids
Styling on steroidsStyling on steroids
Styling on steroids
Mario Noble
 
Testing html5 meetup slideshare
Testing html5 meetup slideshareTesting html5 meetup slideshare
Testing html5 meetup slideshare
Mario Noble
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty gritty
Mario Noble
 
Git presentation
Git presentationGit presentation
Git presentation
Mario Noble
 
Responsive design presentation
Responsive design presentationResponsive design presentation
Responsive design presentation
Mario Noble
 

Recently uploaded (20)

Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 ProfessioMaster tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Kari Kakkonen
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 
What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AIAI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
Buhake Sindi
 
Supercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMsSupercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMs
Francesco Corti
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
Talk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya WeersTalk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya Weers
Kaya Weers
 
Agentic AI - The New Era of Intelligence
Agentic AI - The New Era of IntelligenceAgentic AI - The New Era of Intelligence
Agentic AI - The New Era of Intelligence
Muzammil Shah
 
The 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptxThe 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptx
aptyai
 
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx
2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx
2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx
katalinjordans2
 
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptxFrom Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
Mohammad Jomaa
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Lorenzo Miniero
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Build your own NES Emulator... with Kotlin
Build your own NES Emulator... with KotlinBuild your own NES Emulator... with Kotlin
Build your own NES Emulator... with Kotlin
Artur Skowroński
 
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
SOFTTECHHUB
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 ProfessioMaster tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Master tester AI toolbox - Kari Kakkonen at Testaus ja AI 2025 Professio
Kari Kakkonen
 
New Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDBNew Ways to Reduce Database Costs with ScyllaDB
New Ways to Reduce Database Costs with ScyllaDB
ScyllaDB
 
What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AIAI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
AI in Java - MCP in Action, Langchain4J-CDI, SmallRye-LLM, Spring AI
Buhake Sindi
 
Supercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMsSupercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMs
Francesco Corti
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
Talk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya WeersTalk: On an adventure into the depths of Maven - Kaya Weers
Talk: On an adventure into the depths of Maven - Kaya Weers
Kaya Weers
 
Agentic AI - The New Era of Intelligence
Agentic AI - The New Era of IntelligenceAgentic AI - The New Era of Intelligence
Agentic AI - The New Era of Intelligence
Muzammil Shah
 
The 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptxThe 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptx
aptyai
 
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx
2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx
2025-05-22_Automate__Motivate_Spiff_Meets_Marketing_Cloud.pptx
katalinjordans2
 
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptxFrom Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
From Legacy to Cloud-Native: A Guide to AWS Modernization.pptx
Mohammad Jomaa
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Lorenzo Miniero
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Build your own NES Emulator... with Kotlin
Build your own NES Emulator... with KotlinBuild your own NES Emulator... with Kotlin
Build your own NES Emulator... with Kotlin
Artur Skowroński
 
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
SOFTTECHHUB
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 

Preprocessor presentation

  • 1. CSS Preprocesser Madness LESS/SCSS/Compass/Bootstrap
  • 3. Why Madness? Because you may become crazy for it. Or over it. Or maybe just watching this "Powerpoint" will drive you insane.
  • 4. Preprocessors AKA - The "People's Patch" Our alternative to the cross browser wars. At least for the time being...
  • 5. Learn CSS and good practices first Preprocessors are not a replacement for good coding, planning and design.
  • 6. What is preprocessing? Preprocessing is essentially creating the equivalent of a Photoshop file or a suped up mailing template for your css. It gives you added umph to your work. Sometimes making it easier. Occasionally it might be overkill.
  • 7. Why do it? Do you like to type the same thing over and over? Do you enjoy trying to hunt down a tiny bit of code somewhere in thousands of lines of code and then using find and replace hoping it'll work? No? Use preprocessing.
  • 8. Most of all - DRY practices Don't Repeat Yourself
  • 9. Other reasons ● CSS 3 browser prefixes ● Responsive design ● Other people are using it, so you want to have a clue. ● Efficiency ● Better organization ● Faster sites and better SEO
  • 10. Disadvantages ● Learning curve ● Team Maintenance ● Yet another layer ● Code bloat ● Selectoritis
  • 11. Methods and Approaches ● SASS/SCSS ● LESS ● Stylus ● cleverCSS ● cssCrush ● prefixer (http://prefixr.com/) ● force browser to interpret PHP as CSS
  • 12. We're going over the two most popular preprocessors tonight LESS and SASS/SCSS We'll be glossing over some stuff in the interest of time and clarity
  • 14. Let's go over what they share Each of them now share most of each others capabilities with some minor differences in syntax. The following examples are from Chris Eppstein's gits on: https://gist.github. com/674726 Thanks Chris!
  • 15. Variables (placeholders) Sass | Less -----------------+----------------- $color: red; | @color: red; div { | div { color: $color; | color: @color; } | } Becomes div { color: #ff0000; }
  • 16. Nesting (outlining) Sass | Less -------------------+----------------- p { | p { a { | a { color: red; | color: red; &:hover { | &:hover { color: blue; | color: blue; } } } } } Becomes p a {color: red;} p a:hover {color: blue;}
  • 17. Mixins (mini-templates) Sass | Less ----------------------------------+---------------------------------- @mixin bordered { | .bordered { border-top: dotted 1px black; | border-top: dotted 1px black; border-bottom: solid 2px black; | border-bottom: solid 2px black; } | } | #menu a { | #menu a { @include bordered; | .bordered; } | } Becomes .bordered { border-top: dotted 1px black; border-bottom: solid 2px black; } #menu a { border-top: dotted 1px black; border-bottom: solid 2px black; }
  • 18. Mixins with arguments (adverbs/adjectives) Sass | Less ----------------------------------+---------------------------------- @mixin bordered($width: 2px) { | .bordered(@width: 2px) { border: $width solid black; | border: @width solid black; } | } | #menu a { | #menu a { @include bordered(4px); | .bordered(4px); } | } Becomes #menu a { border: 4px solid #000000; }
  • 19. Numbers Sass: Less: 1cm * 1em => 1 cm * em 1cm * 1em => Error 2in * 3in => 6 in * in 2in * 3in => 6in (1cm / 1em) * 4em => 4cm (1cm / 1em) * 4em 2in + 3cm + 2pc => 3.514in => Error 3in / 2in => 1.5 2in + 3cm + 2pc => Error 3in / 2in => 1.5in
  • 20. Imports (Get that there file!) @import "somefile.less"; @import "somefile"; @import "somefile.scss"; @import "somefile"; @import "somedirectory/somefile.scss";
  • 21. Interpolation (stick it in there) SCSS style LESS style /* style.scss */ @base-url: "http://assets.fnord.com"; $side: top; background-image: url("@{base-url} /images/bg.png"); $radius: 10px; Becomes: .rounded- { border-#{$side}-radius: $radius; background-image: url("http://assets.fnord. com/images/bg.png");.someclass { -moz-border-radius-#{$side}: $radius; color: #333; -webkit-border-#{$side}-radius: $radius; } }
  • 22. Escaping (take it literally) LESS .class { filter: ~"ms:alwaysHasItsOwnSyntax.For. Stuff()"; } SASS .class { filter: #{"'ms:alwaysHasItsOwnSyntax.For. Stuff()'"}; } Becomes: .class {filter: ms:alwaysHasItsOwnSyntax.For.Stuff();}
  • 23. Comments Both LESS and SCSS use the same comment structure. // is a note in the authoring file /* some note */ is published to the compiled file.
  • 24. @media query tweaking LESS (for SASS/SCSS replace @ with $ for Becomes: variables) .profile-pic { @break-small: 320px; float: left; @break-large: 1200px; width: 250px; } @media screen and (max-width: .profile-pic { 320px) { float: left; .profile-pic { width: 250px; width: 100px; float: none; @media screen and (max-width: @break-small) { } width: 100px; } float: none; @media screen and (min-width: 1200px) { } .profile-pic { @media screen and (min-width: @break-large) { float: right; float: right; } } } }
  • 25. Differences As with anything, there are advantages and disadvantages of going with various options. LESS and SASS are no different. Or rather they are in some ways...
  • 26. Extra features of SASS/SCSS ● Can properly "extend" other classes. ● True if, for, while and each control directives (Logic) ● Global scoping of variables ● Compass (sprites) ● Origin line reporting ● Good Rails integration ● Various output styles ● Real functions that return values
  • 27. Extra features of LESS ● Namespacing ● Guards and Pattern Matching ● Easy compile "on the fly" with a single JavaScript file. ● Variables as constants ● Twitter Bootstrap ● Usual scope practices ● JavaScript evaluation
  • 28. To compile locally or on the server? Considerations: Performance Coordination Caching Server install
  • 29. Let's demo some Bootstrap n' Stuff! Go Charles go!
  • 31. Hands on part! Let's do LESS first Get the example material or use your own http://files.meetup.com/1962521/basicHtmlCss.zip Get the basic js http://lesscss.org - bonus points - download twitter bootstrap Get a complier Mac OSX http://incident57.com/less/ Windows http://winless.org/ Linux/Mac/PC http://wearekiss.com/simpless Get an editor or download the code hinters http://www.sublimetext.com/
  • 32. Already have the LESS stuff? To install SASS/SCSS Go here: http://sass-lang.com/tutorial.html Download the Windows Installer if you're on Windows. http://rubyinstaller.org/ After that, go to http://compass-style.org/install/ Follow instructions to install both SASS and Compass Download either Scout http://mhs.github.com/scout-app/ Compass app is good too. Just paid. Configure your editor I recommend SublimeText along with the Package Installer to install SCSS/LESS code hinting.
  • 33. "Converting" your existing CSS Really just nests it. LEAST http://toki-woki.net/p/least/ SASS # Convert Sass to SCSS $ sass-convert style.css style.scss
  • 34. LESS useful tools if using the js to compile. After you put this into your files: <link rel="stylesheet/less" type="text/css" href=" styles.less"> <script src="less.js" type="text/javascript" ></script> Put this after your file name in the url: #!watch Chrome users: --allow-file-access-from-files in shortcut or use a local server mac : terminal ; open /Applications/Google Chrome.app --args --allow-file-access-from-files
  • 35. Compiling You can use tools or the command line. SCSS users may need to delve into their config.rb file or just use the tools. LESS users might just want to use the tools to setup publish paths.
  • 36. Let's have fun with variables @myvariable or $myvariable
  • 38. Mixins @mixin mymixin { } @include mymixin { } .somemixin { } .anotherclass { .somemixin }
  • 39. Mixins with parameters @mixin mymixin($hello); @include mymixin(10px); .somemixin(@hello) .somemixin (10px);
  • 40. Numbers width: $navbar-width/$items - 10px; color: @base-color * 3;
  • 42. Gotchas LESS Keep your import structure flat. SCSS Watch out for imports with .less or not.
  • 43. Congratz!!!! You has mad skillz nowz!
  • 44. Q&A