SlideShare a Scribd company logo
3 Steps to Make
Better & Faster
   Frontends
SCSS > DRY CSS
Compass > Simple CCS3
Lemonade > Easy Sprites
gem install haml
Variables
$my-color: #ab42ef;

body {
  background: $my-color;
}
Color Calculations
h1 {
  background:
     lighten($my-color, 23%);
  color:
     darken(#c24, 10%);
  border-color:
     desaturate(red, 50%);
}
Color Functions
★ opacify(color, amount)
★ transparentize(color, amount)

★ lighten(color, amount)

★ darken(color, amount)

★ saturate(color, amount)

★ desaturate(color, amount)

★ adjust-hue(color, degrees)

★ mix(color1, color2, weight)

★ grayscale(color)

★ complement(color)
RGBA Colors
h2 {
  background: rgba(#00f, 0.7);
}
                   R, G, B
                   #hex
                 colorconst
                 $variables
Cascading
h1 {
  color: red;
  a {
     color: blue;
  }
}
Mixins
@mixin my-style {
  background: red;
}

.my-box {
  @include my-style;
}
Mixin Parameters
@mixin my-style($color: red) {
  background: darken($color, 5%);
}

.my-box {
  @include my-style(#ff0);
}
Cascading Mixins
@mixin my-style {
  a {
    background: red;
  }
}

.my-box {
  @include my-style;
}
Extending
.box {
  background: red;
}

.bordered-box {
  border: 1px black solid;
  @extend .box;
}
Result
.box, .bordered-box {
  background: red;
}

.bordered-box {
  border: 1px black solid;
}
@extend
      =
inverse mixin
Alternative Syntax
=my-style($color: red)
  background: darken($color, 5%)

.my-box
  color: red
  +my-style(#ff0)
  a,                  *.scss
  span
     color: blue      *.sass
More to Learn
★   Include partials
    (no asset packer needed)
★   Auto compress CSS files
★   @if, @for, @while syntax
★   “&” as current cascading placeholder
SCSS > DRY CSS
Compass > Simple CCS3
Lemonade > Easy Sprites
gem install
  compass
CSS3
@import "compass";

.box {
  background: red;
  @include border-radius(4px);
  @include box-shadow(
    rgba(#ccc, 0.5),
    3px, 3px, 5px));
}
Helpers
h1 {
  @include ellipsis;
  @include clearfix;
}

a {
  @include hover-link;
}
Frameworks
@import "blueprint";

@include blueprint;

.box {
  @include column(3);
}
More to Learn
★   Easy to extend with your own gem
★   Use other frameworks
    (960gs, suzy, YUI, YAML, jqTouch, …)
★   Write own frameworks
SCSS > DRY CSS
Compass > Simple CCS3
Lemonade > Easy Sprites
gem install
 lemonade
Simple Sprites
.add {
  background:
    sprite-image("icons/pl.png");
}

.remove {
  background:
    sprite-image("icons/rm.png");
}
               all icons by p.yusukekamiyamane.com (CC by 3.0)
Output
.add {
  background:
    url("icons.png");
}

.remove {
  background:
    url("icons.png") 0 -16px;
}
Right Aligned
.something {
  background:
    sprite-image("i/wide.png");
}
a.next {
  background: yellow no-repeat
    sprite-image("i/n.png", 100%);
  padding-right: 20px;
}
Result
.something {
  background:
    url("i.png");
}
                  Example link
a.next {
  background: yellow no-repeat
    url("i.png") 100% -20px;
  padding-right: 20px;
}
Empty Space
.add {
  background:
    sprite-image("icons/pl.png");
}
.remove {
  background: yellow no-repeat
    sprite-image("icons/rm.png");
  padding: 20px;
}
Could be Better
.add {
  background:
    url("icons.png");
}
.remove {             Example link
  background:
    url("icons.png") 0 -16px;
  padding: 20px;
}
Empty Space
.add {
  background:
    sprite-image("icons/pl.png");
}
.remove {
  background: yellow no-repeat
    sprite-image("icons/rm.png",
       0, 0, 20px);
  padding: 20px; }
Just Perfect
.add {
  background:
    url("icons.png");
}
.remove {             Example link
  background:
    url("icons.png") 0 -36px;
  padding: 20px;
}
Sprite Generation
★   Sprite image named by directory:
    “icons/*.png” > “icons.png”

★   Background position added only if needed

★   Add “no-repeat” by yourself:
    background:
      sprite-image("…") no-repeat;
Any questions?
Happy forking:
http://github.com/nex3/haml
http://github.com/chriseppstein/compass
http://github.com/hagenburger/lemonade
Further reading:
http://www.sass-lang.com
http://www.compass-style.org/docs/
http://www.hagenburger.net/BLOG/
Lemonade-CSS-Sprites-for-Sass-
Compass.html
last name
first name


             nico@hagenburger.net
    e-mail
              twitter
                        blog

More Related Content

PDF
Big Frontends Made Simple
PDF
3 ways-to-create-sprites-in-rails
KEY
Rapid Prototyping FTW!!!
PPT
CSS Preprocessors: LESS is more or look SASS-y trying
PPTX
Write LESS. DO more.
PDF
Eye Candy Without Images: Fun With CSS3
PDF
Accelerated Stylesheets
PPTX
Revolver
Big Frontends Made Simple
3 ways-to-create-sprites-in-rails
Rapid Prototyping FTW!!!
CSS Preprocessors: LESS is more or look SASS-y trying
Write LESS. DO more.
Eye Candy Without Images: Fun With CSS3
Accelerated Stylesheets
Revolver

What's hot (20)

PDF
Scaling Rails Sites by default
PDF
CSS Grid Layout
PPT
LESS(CSS preprocessor)
PDF
LESS
PPTX
Intro to CouchDB
PPTX
Obscure Wordpress Functions That Are Actually Quite Useful
PDF
Confoo: You can use CSS for that!
PDF
Big Design Conference: CSS3
KEY
Sass, Compass and the new tools - Open Web Camp IV
PDF
Accelerated Native Mobile Development with the Ti gem
PDF
Getting Started with Sass & Compass
PDF
Build your website with awestruct and publish it on the cloud with git
PDF
Perch, Patterns and Old Browsers
PDF
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
PDF
Traceur - Javascript.next - Now! RheinmainJS April 14th
PPTX
Introducing grunt, npm and sass
PDF
LESS CSS Pre-processor
KEY
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
PDF
JSON and the APInauts
KEY
Capybara
Scaling Rails Sites by default
CSS Grid Layout
LESS(CSS preprocessor)
LESS
Intro to CouchDB
Obscure Wordpress Functions That Are Actually Quite Useful
Confoo: You can use CSS for that!
Big Design Conference: CSS3
Sass, Compass and the new tools - Open Web Camp IV
Accelerated Native Mobile Development with the Ti gem
Getting Started with Sass & Compass
Build your website with awestruct and publish it on the cloud with git
Perch, Patterns and Old Browsers
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Traceur - Javascript.next - Now! RheinmainJS April 14th
Introducing grunt, npm and sass
LESS CSS Pre-processor
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
JSON and the APInauts
Capybara
Ad

Similar to 3 Steps to Make Better & Faster Frontends (20)

PDF
Preprocessor presentation
KEY
CSS3 is Not Magic Pixie Dust
PDF
"Вклад Adobe в Web". Дмитрий Барановский, Adobe
PDF
Rapid Prototyping
PPT
Learn to love CSS3 | Joomla! Day Deutschland
PPT
Learn to Love CSS3 [English]
PDF
Sass & Compass (Barcamp Stuttgart 2012)
KEY
CSS3 Takes on the World
KEY
Sass, Compass
PDF
GOTO Berlin - You can use CSS for that
PDF
Ext js saas&compass
PDF
Theming Ext JS 4
PDF
Refresh Tallahassee: The RE/MAX Front End Story
PDF
Flash Camp - Degrafa & FXG
KEY
Advanced Technology for Web Application Design
PDF
Finding your way with Sass+Compass
PDF
I Can't Believe It's Not Flash
PDF
CSS Less framework overview, Pros and Cons
KEY
Evrone.ru / BEM for RoR
PDF
Next-level CSS
Preprocessor presentation
CSS3 is Not Magic Pixie Dust
"Вклад Adobe в Web". Дмитрий Барановский, Adobe
Rapid Prototyping
Learn to love CSS3 | Joomla! Day Deutschland
Learn to Love CSS3 [English]
Sass & Compass (Barcamp Stuttgart 2012)
CSS3 Takes on the World
Sass, Compass
GOTO Berlin - You can use CSS for that
Ext js saas&compass
Theming Ext JS 4
Refresh Tallahassee: The RE/MAX Front End Story
Flash Camp - Degrafa & FXG
Advanced Technology for Web Application Design
Finding your way with Sass+Compass
I Can't Believe It's Not Flash
CSS Less framework overview, Pros and Cons
Evrone.ru / BEM for RoR
Next-level CSS
Ad

Recently uploaded (20)

PPTX
400kV_Switchyard_Training_with_Diagrams.pptx
PPTX
Technical-Codes-presentation-G-12Student
PPTX
573393963-choose-your-own-adventure(2).pptx
PDF
DPSR MUN'25 (U).pdf hhhhhhhhhhhhhbbnhhhh
PPTX
Presentation on tradtional textiles of kutch
PPTX
CPAR_QR1_WEEK1_INTRODUCTION TO CPAR.pptx
PPTX
EJ Wedding 520 It's official! We went to Xinyi District to do the documents
PPTX
Neoclassical and Mystery Plays Entertain
PPTX
Green and Orange Illustration Understanding Climate Change Presentation.pptx
PPTX
Military history & Evolution of Armed Forces of the Philippines
PPTX
Review1_Bollywood_Project analysis of bolywood trends from 1950s to 2025
PDF
Close Enough S3 E7 "Bridgette the Brain"
PPTX
Art Appreciation-Lesson-1-1.pptx College
PDF
waiting, Queuing, best time an event cab be done at a time .pdf
PPTX
4277547e-f8e2-414e-8962-bf501ea91259.pptx
PPTX
Theatre Studies - Powerpoint Entertainmn
PPSX
Multiple scenes in a single painting.ppsx
PPTX
current by laws xxxxxxxxxxxxxxxxxxxxxxxxxxx
PPTX
Understanding Postmodernism Powerpoint.pptx
PPTX
CMU-PPT-LACHICA-DEFENSE FOR RESEARCH PRESENTATION
400kV_Switchyard_Training_with_Diagrams.pptx
Technical-Codes-presentation-G-12Student
573393963-choose-your-own-adventure(2).pptx
DPSR MUN'25 (U).pdf hhhhhhhhhhhhhbbnhhhh
Presentation on tradtional textiles of kutch
CPAR_QR1_WEEK1_INTRODUCTION TO CPAR.pptx
EJ Wedding 520 It's official! We went to Xinyi District to do the documents
Neoclassical and Mystery Plays Entertain
Green and Orange Illustration Understanding Climate Change Presentation.pptx
Military history & Evolution of Armed Forces of the Philippines
Review1_Bollywood_Project analysis of bolywood trends from 1950s to 2025
Close Enough S3 E7 "Bridgette the Brain"
Art Appreciation-Lesson-1-1.pptx College
waiting, Queuing, best time an event cab be done at a time .pdf
4277547e-f8e2-414e-8962-bf501ea91259.pptx
Theatre Studies - Powerpoint Entertainmn
Multiple scenes in a single painting.ppsx
current by laws xxxxxxxxxxxxxxxxxxxxxxxxxxx
Understanding Postmodernism Powerpoint.pptx
CMU-PPT-LACHICA-DEFENSE FOR RESEARCH PRESENTATION

3 Steps to Make Better & Faster Frontends