SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
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!
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

Weitere ähnliche Inhalte

Was ist angesagt?

CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien 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 CompassClaudina 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 SassThomas 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 SASSJon Dean
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Startededgincvg
 
DRY cross-browser CSS with SASS
DRY cross-browser CSS with SASSDRY cross-browser CSS with SASS
DRY cross-browser CSS with SASSWes Oldenbeuving
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sassKnoldus Inc.
 
LESS CSS Pre-processor
LESS CSS Pre-processorLESS CSS Pre-processor
LESS CSS Pre-processorKannika Kong
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESSjsmith92
 
Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 MinutesPatrick Crowley
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nlHans 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 NewsKaelig Deloumeau-Prigent
 

Was ist angesagt? (20)

CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
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
 
LESS(CSS preprocessor)
LESS(CSS preprocessor)LESS(CSS preprocessor)
LESS(CSS preprocessor)
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Less vs sass
Less vs sassLess vs sass
Less vs sass
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With Sass
 
Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
DRY cross-browser CSS with SASS
DRY cross-browser CSS with SASSDRY cross-browser CSS with SASS
DRY cross-browser CSS with SASS
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
LESS CSS Pre-processor
LESS CSS Pre-processorLESS CSS Pre-processor
LESS CSS Pre-processor
 
CSS3
CSS3CSS3
CSS3
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
 
Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 Minutes
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nl
 
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
 

Andere mochten auch

Turbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & CompassTurbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & CompassAlmog Baku
 
Front End Badassery with Sass
Front End Badassery with SassFront End Badassery with Sass
Front End Badassery with Sassjessabean
 
Stylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSSStylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSSsforst
 
Frontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & CompassFrontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & CompassAndreas Dantz
 
Performance front end language
Performance front end languagePerformance front end language
Performance front end languageWei-Yi Chiu
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob 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/SCSSBerit Hlubek
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quickBilly Shih
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshopShaho Toofani
 
Horario de clases segundo grado
Horario de clases segundo gradoHorario de clases segundo grado
Horario de clases segundo gradoEverardo Diaz Diaz
 

Andere mochten auch (14)

Cms pres
Cms presCms pres
Cms pres
 
Turbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & CompassTurbo theming: Introduction to Sass & Compass
Turbo theming: Introduction to Sass & Compass
 
Front End Badassery with Sass
Front End Badassery with SassFront End Badassery with Sass
Front End Badassery with Sass
 
Stylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSSStylesheet Wrangling with SCSS
Stylesheet Wrangling with SCSS
 
Frontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & CompassFrontend-Entwicklung mit SASS & Compass
Frontend-Entwicklung mit SASS & Compass
 
Performance front end language
Performance front end languagePerformance front end language
Performance front end language
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
老成的Sass&Compass
老成的Sass&Compass老成的Sass&Compass
老成的Sass&Compass
 
Sass(SCSS)について
Sass(SCSS)についてSass(SCSS)について
Sass(SCSS)について
 
Save time by using SASS/SCSS
Save time by using SASS/SCSSSave time by using SASS/SCSS
Save time by using SASS/SCSS
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quick
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshop
 
Horario de clases segundo grado
Horario de clases segundo gradoHorario de clases segundo grado
Horario de clases segundo grado
 
Sass
SassSass
Sass
 

Ähnlich wie Preprocessor presentation

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 languageKatsunori Tanaka
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with SassSven Wolfermann
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compassdrywallbmb
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco 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-compassChris Lee
 
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 ConsSanjoy Kr. Paul
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustKyle 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 sassHuiyi Yan
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & CompassAndreas Dantz
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with SassRob Friesel
 
Pacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSPacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSSteve Krueger
 

Ähnlich wie Preprocessor presentation (20)

Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
Less css
Less cssLess css
Less css
 
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
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
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
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
PostCss
PostCssPostCss
PostCss
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie Dust
 
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)
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sass
 
Sass compass
Sass compassSass compass
Sass compass
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 
Less & Sass
Less & SassLess & Sass
Less & Sass
 
Workshop 6: Designer tools
Workshop 6: Designer toolsWorkshop 6: Designer tools
Workshop 6: Designer tools
 
Pacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSPacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASS
 

Mehr von 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 GSAPMario Noble
 
Fun with css frameworks
Fun with css frameworksFun with css frameworks
Fun with css frameworksMario Noble
 
Styling on steroids
Styling on steroidsStyling on steroids
Styling on steroidsMario Noble
 
Testing html5 meetup slideshare
Testing html5 meetup slideshareTesting html5 meetup slideshare
Testing html5 meetup slideshareMario Noble
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty grittyMario Noble
 
Git presentation
Git presentationGit presentation
Git presentationMario Noble
 
Responsive design presentation
Responsive design presentationResponsive design presentation
Responsive design presentationMario Noble
 

Mehr von 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
 
Fun with css frameworks
Fun with css frameworksFun with css frameworks
Fun with css frameworks
 
Styling on steroids
Styling on steroidsStyling on steroids
Styling on steroids
 
Testing html5 meetup slideshare
Testing html5 meetup slideshareTesting html5 meetup slideshare
Testing html5 meetup slideshare
 
Html 5 mobile - nitty gritty
Html 5 mobile - nitty grittyHtml 5 mobile - nitty gritty
Html 5 mobile - nitty gritty
 
Git presentation
Git presentationGit presentation
Git presentation
 
Responsive design presentation
Responsive design presentationResponsive design presentation
Responsive design presentation
 
Html5 css3pres
Html5 css3presHtml5 css3pres
Html5 css3pres
 

Kürzlich hochgeladen

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Kürzlich hochgeladen (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

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!
  • 30.
  • 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