SlideShare une entreprise Scribd logo
1  sur  97
Dirk Ginader | Yahoo! Inc.

SASS, Compass &
the new Webdev tools



                             @ginader
“CSS Precompilers are
useless. I don’t need them.
 I can write CSS myself.”
                  -- me, early 2010
“CSS3 is awesome! Browsers
can now do rounded corners
      and Everything!”
             -- me, about the same time
“Damn!
writing all those Browser
  prefixes is tedious...”
           -- me, immediately afterwards
“WOAH! Livereload makes
  me forget about ⌘R!”
                -- me, mid 2011
http://livereload.com/
“The Web Developer Wonderland
 (a happy land where browsers don't need a
                Refresh button)
    CSS edits and image changes apply live.
CoffeeScript, SASS, LESS and others just work.”
                          -- the Livereload website
“What does LiveReload do?
LiveReload monitors changes in the file system. As soon
 as you save a file, it is preprocessed as needed, and the
                  browser is refreshed.
Even cooler, when you change a CSS file or an image, the
browser is updated instantly without reloading the page.”
                               -- the Livereload website
writing 9 lines of CSS to
   create 1 simple cross
browser gradient is a PITA...
                -- everybody, all the time
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#444444', endColorstr='#999999');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#444444', endColorstr='#999999')";
}
wait a second...
well if it’s *THAT* easy
   I could as well give
        it a try, right?
me, after having seen this toggle countless times...
http://sass-lang.com/
“Sass makes CSS fun again. Sass is an extension of
    CSS3, adding nested rules, variables, mixins,
 selector inheritance, and more. It’s translated to
well-formatted, standard CSS using the command
      line tool or a web-framework plugin.”
                                 -- the Sass Website
$ gem install sass
$ sudo gem install sass
alright - let’s see what
     this can do...
Mixins!
reusable chunks of code
/* style.scss */

@mixin linear-gradient {
  background-image: linear-gradient(top, #444, #999);
}

.box-with-gradient {
  @include linear-gradient;
}

.another-box-with-same-gradient {
  @include linear-gradient;
}
$ sass --watch style.scss:style.css
$ sass --watch my/sass:my/css
becomes
/* style.css */

.box-with-gradient {
  background-image: linear-gradient(top, #444, #999);
}

.another-box-with-same-gradient {
  background-image: linear-gradient(top, #444, #999);
}
Mixins can have Params
/* style.scss */

@mixin linear-gradient($from, $to) {
  background-image: linear-gradient(top, $from, $to);
}
/* style.scss */
@mixin linear-gradient($from, $to) {
  background-color: $to;
  background-image:
    -webkit-gradient(linear,left top,left bottom,
      color-stop(0, $from),color-stop(1, $to));
  background-image:
    -webkit-linear-gradient(top, $from, $to);
  background-image:
    -moz-linear-gradient(top, $from, $to);
  background-image:
    -ms-linear-gradient(top, $from, $to);
  background-image:
    -o-linear-gradient(top, $from, $to);
  background-image:
    linear-gradient(top, bottom, $from, $to);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    quote(progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to'));
}
/* style.scss */

.box_gradient {
  @include linear-gradient(#444444, #999999);
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to'); HUH?
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to'); HUH?
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='$from', endColorstr='$to')";HUH?
}
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#interpolation_
/* style.scss */
@mixin linear-gradient($from, $to) {
  background-color: $to;
  background-image:
    -webkit-gradient(linear,left top,left bottom,
      color-stop(0, $from),color-stop(1, $to));
  background-image:
    -webkit-linear-gradient(top, $from, $to);
  background-image:
    -moz-linear-gradient(top, $from, $to);
  background-image:
    -ms-linear-gradient(top, $from, $to);
  background-image:
    -o-linear-gradient(top, $from, $to);
  background-image:
    linear-gradient(top, bottom, $from, $to);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#{$from}', endColorstr='#{$to}');
  -ms-filter:
    quote(progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#{$from}', endColorstr='#{$to}'));
}
/* style.scss */

.box_gradient {
  @include linear-gradient(#444444, #999999);
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#444444', endColorstr='#999999');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#444444', endColorstr='#999999')";
}
/* style.css */
.box_gradient {
  background-color: #999999;
  background-image:
    -webkit-gradient(linear, left top, left bottom,
      color-stop(0, #444444), color-stop(1, #999999));
  background-image:
    -webkit-linear-gradient(top, #444444, #999999);
  background-image:
    -moz-linear-gradient(top, #444444, #999999);
  background-image:
    -ms-linear-gradient(top, #444444, #999999);
  background-image:
    -o-linear-gradient(top, #444444, #999999);
  background-image:
    linear-gradient(top, bottom, #444444, #999999);
  filter:
    progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#444444', endColorstr='#999999');
  -ms-filter:
    "progid:DXImageTransform.Microsoft.gradient(
      startColorstr='#444444', endColorstr='#999999')";
}
write once and reuse
/* style.scss */

.box-with-gradient {
  @include linear-gradient(#444444, #999999);
}

.box-with-another-gradient {
  @include linear-gradient(#000, #fff);
}
wait - I never have to
write prefixes again?
         Ever?
Ok. I’m convinced -
what else do we have?
Nesting!
no more repetitive
          selector writing!
/* style.scss */                    /* style.css */
#navbar {                           #navbar {
  width: 80%;                         width: 80%;
  height: 23px;                       height: 23px; }
                                      #navbar ul {
    ul { list-style-type: none; }       list-style-type: none; }
    li {                              #navbar li {
      float: left;                      float: left; }
      a { font-weight: bold; }          #navbar li a {
    }                                     font-weight: bold; }
}
even properties
         are nestable!
/* style.scss */     /* style.css */
.fakeshadow {        .fakeshadow {
  border: {            border-style: solid;
    style: solid;      border-left-width: 4px;
    left: {            border-left-color: #888;
      width: 4px;      border-right-width: 2px;
      color: #888;     border-right-color: #ccc; }
    }
    right: {
      width: 2px;
      color: #ccc;
    }
  }
}
use the & (parent reference)
    i.e. for pseudoclasses
/* style.scss */                  /* style.css */
a {                               a {
  color: #ce4dd6;                   color: #ce4dd6; }
  &:hover { color: #ffb3ff; }       a:hover {
  &:visited { color: #c458cb; }       color: #ffb3ff; }
  .module &{                        a:visited {
  !color: red;                        color: #c458cb; }
  }                                 .module a {
}                                     color: red; }
Variables!
define standard settings and
 reuse across your project
/* style.scss */                  /* style.css */
                                  #navbar {
$main-color: #ce4dd6;               border-bottom-color: #ce4dd6;
$style: solid;                      border-bottom-style: solid; }

#navbar {                         a {
  border-bottom: {                  color: #ce4dd6; }
    color: $main-color;             a:hover {
    style: $style;                    border-bottom: solid 1px; }
  }
}

a {
  color: $main-color;
  &:hover {
     border-bottom: $style 1px;
  }
}
built in functions!
modify and transform
/* style.scss */                       /* style.css */
$linkcolor: #ce4dd6;                   a {
                                         color: #ce4dd6; }
a {
                                         a:hover {
  color: $linkcolor;
                                           color: #f0c9f3; }
  &:hover {
                                         a:active {
    color: lighten($linkcolor, 30%);
                                           color: #6b1a70; }
  }
  &:active {
    color: darken($linkcolor, 30%);
  }
}
calculate!
Boundary of the content container




height            width




         margin             padding
                  border
the Box Model
  content area width
   + left padding
   + right padding
   + left border
   + right border

  = total box width
calculate the s**t out
        of the Box Model!
/* style.scss */                     /* style.css */
                                     .box {
$box-width : 100px;                    margin: 10px;
$box-border : 3px;                     padding: 10px;
$box-padding : 10px;                   border: 3px solid black;
$box-margin : 10px;                    width: 74px; }

.box{
! margin : $box-margin;
! padding : $box-padding;
! border: $box-border solid black;
! width : $box-width
! !     ! - $box-border * 2
! ! !     - $box-padding * 2;
}
@import
@import?
isn’t that in CSS already?
         Yes it is - but...
combine them instead of
loading one after the other!
  /* style.scss */       /* style.css */
                         .box {
  @import 'box-model';     width: 74px;
  @import 'calculate';     margin: 10px; }
  @import 'function';
                         #navbar {
                           width: 800px; }
                           #navbar li {
                             float: left;
                             width: 150px; }

                         a {
                           color: #ce4dd6; }
                           a:hover {
                             color: #f0c9f3; }
                           a:active {
                             color: #6b1a70; }
http://compass-style.org/
“Compass is an open-
source CSS Authoring
    Framework.”
           -- the Compass website
“Compass is an excellent set of
ready made and well documented
CSS3 mixins, functions and helpers
 that make SASS more awesome”
                              -- me
$ sudo gem update --system
$ sudo gem install compass
$ cd <myproject>
$ compass install bare
$ compass watch
CSS3 mixins
•   Appearance          •   Flexbox

•   Background Clip     •   Box Shadow

•   Background Origin   •   Box Sizing

•   Background Size     •   Columns

•   Border Radius       •   Filter
CSS3 mixins
•   Font Face         •   CSS Regions

•   Hyphenation       •   Text Shadow

•   Gradients         •   Transform

•   Inline Block      •   Transition

•   Opacity
http://paulirish.com/2012/box-sizing-border-box-ftw/
/* style.scss */
.box{
  $experimental-support-for-svg: true;
  @include background-image(
  !linear-gradient(
  !! left,
  !! #2ac363, #cd8c14, #9c4cc2
  !)
  );
  width: 80px;
  height: 80px;
}
/* style.css */
.box {
  background-image: url('data:image/svg
+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2
ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM
+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblV
zZSIgeDE9IjAlIiB5MT0iNTAlIiB4Mj0iMTAwJSIgeTI9IjUwJSI
+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzJhYzM2MyIvPjxzdG9wIG9mZnNldD0
iNTAlIiBzdG9wLWNvbG9yPSIjY2Q4YzE0Ii8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWN
vbG9yPSIjOWM0Y2MyIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM
+PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJ
sKCNncmFkKSIgLz48L3N2Zz4g');
  background-size: 100%;
  background-image: -webkit-gradient(linear, 0% 50%, 100% 50%, color-
stop(0%, #2ac363), color-stop(50%, #cd8c14), color-stop(100%, #9c4cc2));
  background-image: -webkit-linear-gradient(left, #2ac363, #cd8c14,
#9c4cc2);
  background-image: -moz-linear-gradient(left, #2ac363, #cd8c14,
#9c4cc2);
  background-image: -o-linear-gradient(left, #2ac363, #cd8c14, #9c4cc2);
  background-image: -ms-linear-gradient(left, #2ac363, #cd8c14,
#9c4cc2);
  background-image: linear-gradient(left, #2ac363, #cd8c14, #9c4cc2);
  width: 80px;
  height: 80px;
}
http://www.colorzilla.com/gradient-editor/
best practices built in
/* style.scss */           /* style.css */
.inline-box{               .inline-box {
! @include inline-block;     display: -moz-inline-box;
}                            -moz-box-orient: vertical;
                             display: inline-block;
                             vertical-align: middle;
                             *vertical-align: auto;
                           }

                           .inline-box {
                             *display: inline;
                           }
best practices built in
/* style.scss */       /* style.css */
.box{                  .box {
! @include clearfix;     overflow: hidden;
}                        *zoom: 1;
                       }
best practices built in
/* style.scss */           /* style.css */

.other-box{                .other-box {
! @include pie-clearfix;     *zoom: 1;
}                          }
                           .other-box:after {
                             content: "";
                             display: table;
                             clear: both;
                           }
helpers
did you *EVER* expect
        Sprites to be fun?
@import "compass";           .icon-sprite, .icon-mail-attachment,
                             .icon-mail-delete, .icon-mail-reply {
@import "icon/*.png";          background:
                                 url('../images/icon-s10b2c68b42.png')
@include all-icon-sprites;       no-repeat;
                             }
                             .icon-mail-attachment {
                               background-position: -26px -2771px;
                             }
                             .icon-mail-delete {
                               background-position: -27px -2658px;
                             }
                             ...
@import "compass";

$icon-spacing: 100px;
$icon-position: 50%;

@import "icon/*.png";

.attachment{
    @include icon-sprite(mail-attachment);
}
.delete{
    @include icon-sprite(mail-delete);
}
.reply{
    @include icon-sprite(mail-reply);
}
@import "compass";

$icon-layout: diagonal;

@import "icon/*.png";

.attachment{
    @include icon-sprite(mail-attachment);
}
.delete{
    @include icon-sprite(mail-delete);
}
.reply{
    @include icon-sprite(mail-reply);
}
.attachment{                       .attachment {
  background:                        background: url('data:image/
    inline-image(                  png;base64,iVBORw0KGgoAAAANSUh
      'icon/mail-attachment.png'   EUgAAAA0AAAAOBAMAAAAGUYvhAAAAA
    ) no-repeat;                   3NCSVQICAjb4U/gAAAAHlBMVEX///
}                                  8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
                                   AAAAAACGjDitAAAACnRSTlMAESIzRF
                                   Vmd4iZu4Nz1gAAAAlwSFlzAAALEgAA
                                   CxIB0t1+/
                                   AAAABR0RVh0Q3JlYXRpb24gVGltZQA
                                   0LzQvMTI1uCR/
                                   AAAAHHRFWHRTb2Z0d2FyZQBBZG9iZS
                                   BGaXJld29ya3MgQ1M0BrLToAAAAFNJ
                                   REFUCJljYAACjWkCIIqpRSwBzDVgLg
                                   BxGwTEA0Bc9sAyMLdMPAHMTSxjhHKb
                                   GBg4DAvLOBQYGNQZ1EFcBg2gEJDLwG
                                   HAAuIyMJangg1nYARTACNTDXDO7nbI
                                   AAAAAElFTkSuQmCC') no-repeat;
                                   }
                                   ...
li{
! padding-left:
     image-width(
       'icon/mail-attachment.png'
     ) + 10;
! background-repeat:no-repeat;
}
please welcome
   the others:
please welcome
         the others:

• Less:
  http://lesscss.org
• Stylus:
  http://learnboost.github.com/stylus/
SASS ultimately won out because it's
   the most mature, easiest to find
 information and help about, seems
 to have the most active and robust
development, and has the least bugs.
                       -- Chris Coyier, just recently




 http://css-tricks.com/musings-on-preprocessing/
thank you ;-)

•http://ginader.com
•http://twitter.com/ginader
•http://github.com/ginader
•http://www.slideshare.net/ginader
•http://speakerrate.com/speakers/
 225-ginader

Contenu connexe

Tendances

HTML5 Dev Conf - Sass, Compass & the new Webdev tools
HTML5 Dev Conf - Sass, Compass &  the new Webdev toolsHTML5 Dev Conf - Sass, Compass &  the new Webdev tools
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
Dirk Ginader
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
Itai Koren
 

Tendances (20)

Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
HTML5 Dev Conf - Sass, Compass &  the new Webdev toolsHTML5 Dev Conf - Sass, Compass &  the new Webdev tools
HTML5 Dev Conf - Sass, Compass & the new Webdev tools
 
Theme 23
Theme 23Theme 23
Theme 23
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
CSS3: Ripe and Ready
CSS3: Ripe and ReadyCSS3: Ripe and Ready
CSS3: Ripe and Ready
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y trying
 
Eye Candy Without Images: Fun With CSS3
Eye Candy Without Images: Fun With CSS3Eye Candy Without Images: Fun With CSS3
Eye Candy Without Images: Fun With CSS3
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
3 Steps to Make Better & Faster Frontends
3 Steps to Make Better & Faster Frontends3 Steps to Make Better & Faster Frontends
3 Steps to Make Better & Faster Frontends
 
Big Frontends Made Simple
Big Frontends Made SimpleBig Frontends Made Simple
Big Frontends Made Simple
 
LESS CSS Pre-processor
LESS CSS Pre-processorLESS CSS Pre-processor
LESS CSS Pre-processor
 
The Near Future of CSS
The Near Future of CSSThe Near Future of CSS
The Near Future of CSS
 
LESS(CSS preprocessor)
LESS(CSS preprocessor)LESS(CSS preprocessor)
LESS(CSS preprocessor)
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-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
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
LessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG MeetingLessCSS Presentation @ April 2015 GTALUG Meeting
LessCSS Presentation @ April 2015 GTALUG Meeting
 

Similaire à Sass, Compass and the new tools - Open Web Camp IV

Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
Even Wu
 
Evrone.ru / BEM for RoR
Evrone.ru / BEM for RoREvrone.ru / BEM for RoR
Evrone.ru / BEM for RoR
Dmitry KODer
 
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte eventHTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
Robert Nyman
 

Similaire à Sass, Compass and the new tools - Open Web Camp IV (20)

Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
Learn to love CSS3 | Joomla! Day Deutschland
Learn to love CSS3 | Joomla! Day DeutschlandLearn to love CSS3 | Joomla! Day Deutschland
Learn to love CSS3 | Joomla! Day Deutschland
 
CSS3: Are you experienced?
CSS3: Are you experienced?CSS3: Are you experienced?
CSS3: Are you experienced?
 
Learn to Love CSS3 [English]
Learn to Love CSS3 [English]Learn to Love CSS3 [English]
Learn to Love CSS3 [English]
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie Dust
 
Sass compass
Sass compassSass compass
Sass compass
 
Css3
Css3Css3
Css3
 
Intro to CSS3
Intro to CSS3Intro to CSS3
Intro to CSS3
 
CSS3 pronti all'uso
CSS3 pronti all'usoCSS3 pronti all'uso
CSS3 pronti all'uso
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to Respond
 
Simply Responsive CSS3
Simply Responsive CSS3Simply Responsive CSS3
Simply Responsive CSS3
 
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)
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
 
Advanced CSS Techniques
Advanced CSS TechniquesAdvanced CSS Techniques
Advanced CSS Techniques
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
Responsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da WebResponsive Web Design e a Ubiquidade da Web
Responsive Web Design e a Ubiquidade da Web
 
Html5
Html5Html5
Html5
 
Css3 101
Css3 101Css3 101
Css3 101
 
Evrone.ru / BEM for RoR
Evrone.ru / BEM for RoREvrone.ru / BEM for RoR
Evrone.ru / BEM for RoR
 
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte eventHTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
HTML5 and CSS3 – exploring mobile possibilities - Dynabyte event
 

Plus de Dirk Ginader

Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
Dirk Ginader
 
Javascript done right
Javascript done rightJavascript done right
Javascript done right
Dirk Ginader
 
Accessible Javascript using Frameworks - Barcamp London 5
Accessible Javascript using Frameworks - Barcamp London 5Accessible Javascript using Frameworks - Barcamp London 5
Accessible Javascript using Frameworks - Barcamp London 5
Dirk Ginader
 
Accessible Javascript mit Frameworks - Best of Accessibility 2008
Accessible Javascript mit Frameworks - Best of Accessibility 2008Accessible Javascript mit Frameworks - Best of Accessibility 2008
Accessible Javascript mit Frameworks - Best of Accessibility 2008
Dirk Ginader
 

Plus de Dirk Ginader (17)

Making your Angular.js Application accessible
Making your Angular.js Application accessibleMaking your Angular.js Application accessible
Making your Angular.js Application accessible
 
Teach your Browser new tricks
Teach your Browser new tricksTeach your Browser new tricks
Teach your Browser new tricks
 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!
 
Javascript done right - Open Web Camp III
Javascript done right - Open Web Camp IIIJavascript done right - Open Web Camp III
Javascript done right - Open Web Camp III
 
The accessibility features of Yahoo! Finance
The accessibility features of Yahoo! FinanceThe accessibility features of Yahoo! Finance
The accessibility features of Yahoo! Finance
 
Javascript done right
Javascript done rightJavascript done right
Javascript done right
 
Javascript auf Client und Server mit node.js - webtech 2010
Javascript auf Client und Server mit node.js - webtech 2010Javascript auf Client und Server mit node.js - webtech 2010
Javascript auf Client und Server mit node.js - webtech 2010
 
the 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp IIthe 5 layers of web accessibility - Open Web Camp II
the 5 layers of web accessibility - Open Web Camp II
 
Das Web Als Datenbank Mit Yql Und Pipes
Das Web Als Datenbank Mit Yql Und PipesDas Web Als Datenbank Mit Yql Und Pipes
Das Web Als Datenbank Mit Yql Und Pipes
 
Die 5 Ebenen Barriererfreier Web Entwicklung
Die 5 Ebenen Barriererfreier Web EntwicklungDie 5 Ebenen Barriererfreier Web Entwicklung
Die 5 Ebenen Barriererfreier Web Entwicklung
 
The 5 Layers of Web Accessibility
The 5 Layers of Web AccessibilityThe 5 Layers of Web Accessibility
The 5 Layers of Web Accessibility
 
Accessible Javascript with and without WAI ARIA
Accessible Javascript with and without WAI ARIAAccessible Javascript with and without WAI ARIA
Accessible Javascript with and without WAI ARIA
 
Avoiding common Accessibility mistakes
Avoiding common Accessibility mistakesAvoiding common Accessibility mistakes
Avoiding common Accessibility mistakes
 
Accessible Javascript using Frameworks - Barcamp London 5
Accessible Javascript using Frameworks - Barcamp London 5Accessible Javascript using Frameworks - Barcamp London 5
Accessible Javascript using Frameworks - Barcamp London 5
 
Accessible Javascript mit Frameworks - Best of Accessibility 2008
Accessible Javascript mit Frameworks - Best of Accessibility 2008Accessible Javascript mit Frameworks - Best of Accessibility 2008
Accessible Javascript mit Frameworks - Best of Accessibility 2008
 
Accessible Javascript - Barcamp Brighton 2
Accessible Javascript - Barcamp Brighton 2Accessible Javascript - Barcamp Brighton 2
Accessible Javascript - Barcamp Brighton 2
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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?
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 

Sass, Compass and the new tools - Open Web Camp IV

  • 1. Dirk Ginader | Yahoo! Inc. SASS, Compass & the new Webdev tools @ginader
  • 2. “CSS Precompilers are useless. I don’t need them. I can write CSS myself.” -- me, early 2010
  • 3. “CSS3 is awesome! Browsers can now do rounded corners and Everything!” -- me, about the same time
  • 4. “Damn! writing all those Browser prefixes is tedious...” -- me, immediately afterwards
  • 5. “WOAH! Livereload makes me forget about ⌘R!” -- me, mid 2011
  • 6.
  • 8. “The Web Developer Wonderland (a happy land where browsers don't need a Refresh button) CSS edits and image changes apply live. CoffeeScript, SASS, LESS and others just work.” -- the Livereload website
  • 9. “What does LiveReload do? LiveReload monitors changes in the file system. As soon as you save a file, it is preprocessed as needed, and the browser is refreshed. Even cooler, when you change a CSS file or an image, the browser is updated instantly without reloading the page.” -- the Livereload website
  • 10. writing 9 lines of CSS to create 1 simple cross browser gradient is a PITA... -- everybody, all the time
  • 11. .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#999999'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#999999')"; }
  • 13. well if it’s *THAT* easy I could as well give it a try, right? me, after having seen this toggle countless times...
  • 15. “Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.” -- the Sass Website
  • 17.
  • 18. $ sudo gem install sass
  • 19. alright - let’s see what this can do...
  • 21. reusable chunks of code /* style.scss */ @mixin linear-gradient { background-image: linear-gradient(top, #444, #999); } .box-with-gradient { @include linear-gradient; } .another-box-with-same-gradient { @include linear-gradient; }
  • 22. $ sass --watch style.scss:style.css
  • 23. $ sass --watch my/sass:my/css
  • 24. becomes /* style.css */ .box-with-gradient { background-image: linear-gradient(top, #444, #999); } .another-box-with-same-gradient { background-image: linear-gradient(top, #444, #999); }
  • 25. Mixins can have Params /* style.scss */ @mixin linear-gradient($from, $to) { background-image: linear-gradient(top, $from, $to); }
  • 26. /* style.scss */ @mixin linear-gradient($from, $to) { background-color: $to; background-image: -webkit-gradient(linear,left top,left bottom, color-stop(0, $from),color-stop(1, $to)); background-image: -webkit-linear-gradient(top, $from, $to); background-image: -moz-linear-gradient(top, $from, $to); background-image: -ms-linear-gradient(top, $from, $to); background-image: -o-linear-gradient(top, $from, $to); background-image: linear-gradient(top, bottom, $from, $to); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: quote(progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')); }
  • 27. /* style.scss */ .box_gradient { @include linear-gradient(#444444, #999999); }
  • 28. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 29. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 30. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 31. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 32. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 33. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 34. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 35. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 36. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); HUH? -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')"; }
  • 37. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to'); HUH? -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='$from', endColorstr='$to')";HUH? }
  • 38.
  • 40. /* style.scss */ @mixin linear-gradient($from, $to) { background-color: $to; background-image: -webkit-gradient(linear,left top,left bottom, color-stop(0, $from),color-stop(1, $to)); background-image: -webkit-linear-gradient(top, $from, $to); background-image: -moz-linear-gradient(top, $from, $to); background-image: -ms-linear-gradient(top, $from, $to); background-image: -o-linear-gradient(top, $from, $to); background-image: linear-gradient(top, bottom, $from, $to); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#{$from}', endColorstr='#{$to}'); -ms-filter: quote(progid:DXImageTransform.Microsoft.gradient( startColorstr='#{$from}', endColorstr='#{$to}')); }
  • 41. /* style.scss */ .box_gradient { @include linear-gradient(#444444, #999999); }
  • 42. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#999999'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#999999')"; }
  • 43. /* style.css */ .box_gradient { background-color: #999999; background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #444444), color-stop(1, #999999)); background-image: -webkit-linear-gradient(top, #444444, #999999); background-image: -moz-linear-gradient(top, #444444, #999999); background-image: -ms-linear-gradient(top, #444444, #999999); background-image: -o-linear-gradient(top, #444444, #999999); background-image: linear-gradient(top, bottom, #444444, #999999); filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#999999'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#999999')"; }
  • 44. write once and reuse /* style.scss */ .box-with-gradient { @include linear-gradient(#444444, #999999); } .box-with-another-gradient { @include linear-gradient(#000, #fff); }
  • 45. wait - I never have to write prefixes again? Ever?
  • 46.
  • 47. Ok. I’m convinced - what else do we have?
  • 49. no more repetitive selector writing! /* style.scss */ /* style.css */ #navbar { #navbar { width: 80%; width: 80%; height: 23px; height: 23px; } #navbar ul { ul { list-style-type: none; } list-style-type: none; } li { #navbar li { float: left; float: left; } a { font-weight: bold; } #navbar li a { } font-weight: bold; } }
  • 50. even properties are nestable! /* style.scss */ /* style.css */ .fakeshadow { .fakeshadow { border: { border-style: solid; style: solid; border-left-width: 4px; left: { border-left-color: #888; width: 4px; border-right-width: 2px; color: #888; border-right-color: #ccc; } } right: { width: 2px; color: #ccc; } } }
  • 51.
  • 52. use the & (parent reference) i.e. for pseudoclasses /* style.scss */ /* style.css */ a { a { color: #ce4dd6; color: #ce4dd6; } &:hover { color: #ffb3ff; } a:hover { &:visited { color: #c458cb; } color: #ffb3ff; } .module &{ a:visited { !color: red; color: #c458cb; } } .module a { } color: red; }
  • 54. define standard settings and reuse across your project /* style.scss */ /* style.css */ #navbar { $main-color: #ce4dd6; border-bottom-color: #ce4dd6; $style: solid; border-bottom-style: solid; } #navbar { a { border-bottom: { color: #ce4dd6; } color: $main-color; a:hover { style: $style; border-bottom: solid 1px; } } } a { color: $main-color; &:hover { border-bottom: $style 1px; } }
  • 56. modify and transform /* style.scss */ /* style.css */ $linkcolor: #ce4dd6; a { color: #ce4dd6; } a { a:hover { color: $linkcolor; color: #f0c9f3; } &:hover { a:active { color: lighten($linkcolor, 30%); color: #6b1a70; } } &:active { color: darken($linkcolor, 30%); } }
  • 58. Boundary of the content container height width margin padding border
  • 59.
  • 60. the Box Model content area width + left padding + right padding + left border + right border = total box width
  • 61. calculate the s**t out of the Box Model! /* style.scss */ /* style.css */ .box { $box-width : 100px; margin: 10px; $box-border : 3px; padding: 10px; $box-padding : 10px; border: 3px solid black; $box-margin : 10px; width: 74px; } .box{ ! margin : $box-margin; ! padding : $box-padding; ! border: $box-border solid black; ! width : $box-width ! ! ! - $box-border * 2 ! ! ! - $box-padding * 2; }
  • 63. @import? isn’t that in CSS already? Yes it is - but...
  • 64.
  • 65. combine them instead of loading one after the other! /* style.scss */ /* style.css */ .box { @import 'box-model'; width: 74px; @import 'calculate'; margin: 10px; } @import 'function'; #navbar { width: 800px; } #navbar li { float: left; width: 150px; } a { color: #ce4dd6; } a:hover { color: #f0c9f3; } a:active { color: #6b1a70; }
  • 66.
  • 68. “Compass is an open- source CSS Authoring Framework.” -- the Compass website
  • 69. “Compass is an excellent set of ready made and well documented CSS3 mixins, functions and helpers that make SASS more awesome” -- me
  • 70. $ sudo gem update --system $ sudo gem install compass
  • 71.
  • 72. $ cd <myproject> $ compass install bare $ compass watch
  • 73.
  • 74.
  • 75. CSS3 mixins • Appearance • Flexbox • Background Clip • Box Shadow • Background Origin • Box Sizing • Background Size • Columns • Border Radius • Filter
  • 76. CSS3 mixins • Font Face • CSS Regions • Hyphenation • Text Shadow • Gradients • Transform • Inline Block • Transition • Opacity
  • 78. /* style.scss */ .box{ $experimental-support-for-svg: true; @include background-image( !linear-gradient( !! left, !! #2ac363, #cd8c14, #9c4cc2 !) ); width: 80px; height: 80px; }
  • 79. /* style.css */ .box { background-image: url('data:image/svg +xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2 ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM +PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblV zZSIgeDE9IjAlIiB5MT0iNTAlIiB4Mj0iMTAwJSIgeTI9IjUwJSI +PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzJhYzM2MyIvPjxzdG9wIG9mZnNldD0 iNTAlIiBzdG9wLWNvbG9yPSIjY2Q4YzE0Ii8+PHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWN vbG9yPSIjOWM0Y2MyIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM +PHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJ sKCNncmFkKSIgLz48L3N2Zz4g'); background-size: 100%; background-image: -webkit-gradient(linear, 0% 50%, 100% 50%, color- stop(0%, #2ac363), color-stop(50%, #cd8c14), color-stop(100%, #9c4cc2)); background-image: -webkit-linear-gradient(left, #2ac363, #cd8c14, #9c4cc2); background-image: -moz-linear-gradient(left, #2ac363, #cd8c14, #9c4cc2); background-image: -o-linear-gradient(left, #2ac363, #cd8c14, #9c4cc2); background-image: -ms-linear-gradient(left, #2ac363, #cd8c14, #9c4cc2); background-image: linear-gradient(left, #2ac363, #cd8c14, #9c4cc2); width: 80px; height: 80px; }
  • 81. best practices built in /* style.scss */ /* style.css */ .inline-box{ .inline-box { ! @include inline-block; display: -moz-inline-box; } -moz-box-orient: vertical; display: inline-block; vertical-align: middle; *vertical-align: auto; } .inline-box { *display: inline; }
  • 82. best practices built in /* style.scss */ /* style.css */ .box{ .box { ! @include clearfix; overflow: hidden; } *zoom: 1; }
  • 83. best practices built in /* style.scss */ /* style.css */ .other-box{ .other-box { ! @include pie-clearfix; *zoom: 1; } } .other-box:after { content: ""; display: table; clear: both; }
  • 85. did you *EVER* expect Sprites to be fun? @import "compass"; .icon-sprite, .icon-mail-attachment, .icon-mail-delete, .icon-mail-reply { @import "icon/*.png"; background: url('../images/icon-s10b2c68b42.png') @include all-icon-sprites; no-repeat; } .icon-mail-attachment { background-position: -26px -2771px; } .icon-mail-delete { background-position: -27px -2658px; } ...
  • 86.
  • 87. @import "compass"; $icon-spacing: 100px; $icon-position: 50%; @import "icon/*.png"; .attachment{ @include icon-sprite(mail-attachment); } .delete{ @include icon-sprite(mail-delete); } .reply{ @include icon-sprite(mail-reply); }
  • 88. @import "compass"; $icon-layout: diagonal; @import "icon/*.png"; .attachment{ @include icon-sprite(mail-attachment); } .delete{ @include icon-sprite(mail-delete); } .reply{ @include icon-sprite(mail-reply); }
  • 89.
  • 90. .attachment{ .attachment { background: background: url('data:image/ inline-image( png;base64,iVBORw0KGgoAAAANSUh 'icon/mail-attachment.png' EUgAAAA0AAAAOBAMAAAAGUYvhAAAAA ) no-repeat; 3NCSVQICAjb4U/gAAAAHlBMVEX/// } 8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAACGjDitAAAACnRSTlMAESIzRF Vmd4iZu4Nz1gAAAAlwSFlzAAALEgAA CxIB0t1+/ AAAABR0RVh0Q3JlYXRpb24gVGltZQA 0LzQvMTI1uCR/ AAAAHHRFWHRTb2Z0d2FyZQBBZG9iZS BGaXJld29ya3MgQ1M0BrLToAAAAFNJ REFUCJljYAACjWkCIIqpRSwBzDVgLg BxGwTEA0Bc9sAyMLdMPAHMTSxjhHKb GBg4DAvLOBQYGNQZ1EFcBg2gEJDLwG HAAuIyMJangg1nYARTACNTDXDO7nbI AAAAAElFTkSuQmCC') no-repeat; } ...
  • 91. li{ ! padding-left: image-width( 'icon/mail-attachment.png' ) + 10; ! background-repeat:no-repeat; }
  • 92.
  • 93. please welcome the others:
  • 94. please welcome the others: • Less: http://lesscss.org • Stylus: http://learnboost.github.com/stylus/
  • 95. SASS ultimately won out because it's the most mature, easiest to find information and help about, seems to have the most active and robust development, and has the least bugs. -- Chris Coyier, just recently http://css-tricks.com/musings-on-preprocessing/
  • 96.

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n