SlideShare une entreprise Scribd logo
1  sur  24
Télécharger pour lire hors ligne
Sassy CSS
                           An Introduction to
                         Compass, Sass and Susy

Sunday, October 23, 11
Sass, or Syntactically
                         Awesome Stylesheets

                    • Nesting
                    • Variables
                    • Mixins
                    • Functions
Sunday, October 23, 11
2 Syntaxes:
                               Sass & SCSS

                    •    Both fully support CSS3
                    •    Both compile to clean CSS
                    •    Can convert back and forth from one
                         syntax to the other



Sunday, October 23, 11
Sass
                    •    Whitespace conscious

                    •    Use indents instead of {brackets}
                    •    New lines separate properties, not semicolons;

                    •    Fast to write
                    •    Clean to look at

                    •    Simple to review and edit



Sunday, October 23, 11
SCSS
                    •    More directly an extension of CSS3 than
                         Sass
                    •    Looks more like CSS in format
                    •    Still uses {brackets} and semicolons;




Sunday, October 23, 11
Nesting
                    •    Child selectors can nest under their
                         parents to cut down on repetition: ul, li, a
                    •    Use & to nest pseudo-classes like
                         &:active, &:hover under a
                    •    Nest properties to save time on border-
                         and font-
                    •    Selector inheritance and output styles


Sunday, October 23, 11
Variables, the spice of Sass


                    •    Use $ to declare colors or fonts in one
                         place, making changes or tweaks a snap
                    •    Able to dynamically alter mixins with
                         math the operations +, -, *, /, and %
                    •    Create custom variables for your project




Sunday, October 23, 11
Mixins and Fixins’


                    •    Use ‘@mixin’ to pass a block of styles for
                         properties or selectors
                    •    Use ‘@include’ to then apply without
                         adding a class or copying and pasting

                    •    Again, changes happen in one place and
                         then are updated
                    •    Pass some arguments if you are feelin’ lucky


Sunday, October 23, 11
Super Sass
                    •    Use ‘@import’ to pull in partial style
                         sheets, or ‘partials’ i.e. _sassiest.sass
                    •    Short, sweet, imported directly
                    •    No file extension needed on the import
                    •    “any variables or mixins defined in
                         @imported files are available to the files
                         that import them” - http://sass-lang.com


Sunday, October 23, 11
Get Sass for Yourself
                    •     Install Ruby
                    •     Install Sass gem -> gem install sass
                    •     Start your compiler -> sass --watch
                          style.scss:style.css
                    •     Write away!




Sunday, October 23, 11
Compass
                    •    CSS authoring framework
                    •    Use SCSS or Sass
                    •    Runs on Ruby too
                    •    Don’t write Sass without it -> gem install
                         compass




Sunday, October 23, 11
Compass Core
                    •    Save yourself some time, pre-written
                    •    CSS3 gold
                    •    Common typography styles? No sweat.
                    •    Compass core utilities
                    •    Can also opt to import the Blueprint
                         project, which is fully supported


Sunday, October 23, 11
@import “compass/css3”

                    •     Use kick-sass CSS3 properties and let
                          compass handle the cross-browser code

                    Appearance          Box Shadow   Inline Block

                    Background Clip     Box Sizing   Opacity

                    Background Origin   Columns      Text Shadow

                    Background Size     Font Face    Transform

                    Border Radius       Gradient     Transition

                    Box                 Images



Sunday, October 23, 11
@import “compass/
                                 typography”
                •        style up lists, links, text styling, and vertical
                         rhythm

                    links                 horizontal lists     text replacement

                    hover Link            inline-block lists   vertical rhythm

                    link colors           inline lists         baselines

                    unstyled links        ellipsis             font size

                    lists                 force wrap           line height

                    bullets               no wrap



Sunday, October 23, 11
@import “compass/
                                utilities”
                •        make colors magical, fix floats, pre-hack
                         specific browsers, make sprites easy and
                         make styling tables smart

                    colors             minimums        table striping
                    clearfix            resets          table borders
                    floats              tags            table
                                                       scaffolding
                    hacks              sprites

Sunday, October 23, 11
Susy!
                    •    “A simple grid system that is fully
                         customized to your markup, your grid,
                         your designs, the way you want them.” -
                         @eriiicam the creator
                    •    gem install compass-susy-plugin




Sunday, October 23, 11
Set-up
                    •    Define variables for:
                          •   number of columns in grid
                          •   column width
                          •   gutter width (space between columns)
                          •   side-gutter width



Sunday, October 23, 11
Grids, Grids, Grids
                    •    “fluid on the inside & elastic on the
                         outside” - @eriiicam
                    •    Units: use percentages for a fluid grid and
                         pixels for a fixed grid
                    •    Mixins: use ‘full’ to span the full width
                         and ‘columns’ to declare element widths
                         within the container


Sunday, October 23, 11
How to make it work
                1. It’s just CSS
                2. Compiling and committing: formats and
                using a version control system
                3. Teamwork: #teamSass and using Sass as a
                Team




Sunday, October 23, 11
1. It’s just CSS
                    •    Don’t get carried away
                    •    Check what your css looks like if your
                         changes aren’t showing
                    •    Use CSS best practices, only faster
                    •    Use Compass to generate common CSS
                    •    Remember: Clean Code is Good Code


Sunday, October 23, 11
2. Compiling &
                                Committing
                    •    Be careful when using FireSass
                    •    Watch your compiling stream for errors
                         and deprecations
                    •    The difference between compass compile
                         & compass watch
                    •    Turn of comments, re-compile, commit
                         with... Git


Sunday, October 23, 11
3. Teamwork
                    •    Join team Sass, but don’t become a sass-
                         hole to your team
                    •    Use arguments, but don’t argue over
                         syntax, they work together!
                    •    Pro-tip: Committing JUST the Sass/Scss
                         and compiling CSS on the server,
                         environment-permitting


Sunday, October 23, 11
References & Resources

                    •     Sass: http://sass-lang.com/
                    •     Compass: http://compass-style.org/
                    •     Susy: http://susy.oddbird.net/
                    •     The Sass Way: http://thesassway.com
                    •     On twitter: @thesassway & #teamSass



Sunday, October 23, 11
Thanks!
                    •    dead_arm on drupal.org and twitter




Sunday, October 23, 11

Contenu connexe

Similaire à Css compass sasssusy

Flexbox, Grid and Sass
Flexbox, Grid and SassFlexbox, Grid and Sass
Flexbox, Grid and SassSeble Nigussie
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
960 Grid System - A hands-on introduction
960 Grid System -  A hands-on introduction960 Grid System -  A hands-on introduction
960 Grid System - A hands-on introductionMario Hernandez
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sasschriseppstein
 
BDUG Responsive Web Theming - 7/23/12
BDUG Responsive Web Theming - 7/23/12BDUG Responsive Web Theming - 7/23/12
BDUG Responsive Web Theming - 7/23/12ucbdrupal
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sassKnoldus Inc.
 
What is-sass-by-lucas-castro
What is-sass-by-lucas-castroWhat is-sass-by-lucas-castro
What is-sass-by-lucas-castroLucas Castro
 

Similaire à Css compass sasssusy (9)

Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 
Flexbox, Grid and Sass
Flexbox, Grid and SassFlexbox, Grid and Sass
Flexbox, Grid and Sass
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
960 Grid System - A hands-on introduction
960 Grid System -  A hands-on introduction960 Grid System -  A hands-on introduction
960 Grid System - A hands-on introduction
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
 
BDUG Responsive Web Theming - 7/23/12
BDUG Responsive Web Theming - 7/23/12BDUG Responsive Web Theming - 7/23/12
BDUG Responsive Web Theming - 7/23/12
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
Sass
SassSass
Sass
 
What is-sass-by-lucas-castro
What is-sass-by-lucas-castroWhat is-sass-by-lucas-castro
What is-sass-by-lucas-castro
 

Plus de Zivtech, LLC

Shift left testing for continuous collaboration
Shift left testing for continuous collaborationShift left testing for continuous collaboration
Shift left testing for continuous collaborationZivtech, LLC
 
DrupalCon San Francisco- The State of Drupal as a Web Application & Product ...
DrupalCon San Francisco-  The State of Drupal as a Web Application & Product ...DrupalCon San Francisco-  The State of Drupal as a Web Application & Product ...
DrupalCon San Francisco- The State of Drupal as a Web Application & Product ...Zivtech, LLC
 
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation Zivtech, LLC
 
Drupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt Cheney
Drupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt CheneyDrupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt Cheney
Drupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt CheneyZivtech, LLC
 
Drupal Problem-Solving Techniques
Drupal Problem-Solving TechniquesDrupal Problem-Solving Techniques
Drupal Problem-Solving TechniquesZivtech, LLC
 
The business case for contributing code
The business case for contributing codeThe business case for contributing code
The business case for contributing codeZivtech, LLC
 
Drupal Presentation @ the Higher Education Web Symposium
Drupal Presentation @ the Higher Education Web SymposiumDrupal Presentation @ the Higher Education Web Symposium
Drupal Presentation @ the Higher Education Web SymposiumZivtech, LLC
 

Plus de Zivtech, LLC (7)

Shift left testing for continuous collaboration
Shift left testing for continuous collaborationShift left testing for continuous collaboration
Shift left testing for continuous collaboration
 
DrupalCon San Francisco- The State of Drupal as a Web Application & Product ...
DrupalCon San Francisco-  The State of Drupal as a Web Application & Product ...DrupalCon San Francisco-  The State of Drupal as a Web Application & Product ...
DrupalCon San Francisco- The State of Drupal as a Web Application & Product ...
 
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
Probo.ci Drupal 4 Gov Devops 1/2 day Presentation
 
Drupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt Cheney
Drupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt CheneyDrupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt Cheney
Drupaldelphia 2014 - Mission Bicycle Case Study - Slides by Matt Cheney
 
Drupal Problem-Solving Techniques
Drupal Problem-Solving TechniquesDrupal Problem-Solving Techniques
Drupal Problem-Solving Techniques
 
The business case for contributing code
The business case for contributing codeThe business case for contributing code
The business case for contributing code
 
Drupal Presentation @ the Higher Education Web Symposium
Drupal Presentation @ the Higher Education Web SymposiumDrupal Presentation @ the Higher Education Web Symposium
Drupal Presentation @ the Higher Education Web Symposium
 

Css compass sasssusy

  • 1. Sassy CSS An Introduction to Compass, Sass and Susy Sunday, October 23, 11
  • 2. Sass, or Syntactically Awesome Stylesheets • Nesting • Variables • Mixins • Functions Sunday, October 23, 11
  • 3. 2 Syntaxes: Sass & SCSS • Both fully support CSS3 • Both compile to clean CSS • Can convert back and forth from one syntax to the other Sunday, October 23, 11
  • 4. Sass • Whitespace conscious • Use indents instead of {brackets} • New lines separate properties, not semicolons; • Fast to write • Clean to look at • Simple to review and edit Sunday, October 23, 11
  • 5. SCSS • More directly an extension of CSS3 than Sass • Looks more like CSS in format • Still uses {brackets} and semicolons; Sunday, October 23, 11
  • 6. Nesting • Child selectors can nest under their parents to cut down on repetition: ul, li, a • Use & to nest pseudo-classes like &:active, &:hover under a • Nest properties to save time on border- and font- • Selector inheritance and output styles Sunday, October 23, 11
  • 7. Variables, the spice of Sass • Use $ to declare colors or fonts in one place, making changes or tweaks a snap • Able to dynamically alter mixins with math the operations +, -, *, /, and % • Create custom variables for your project Sunday, October 23, 11
  • 8. Mixins and Fixins’ • Use ‘@mixin’ to pass a block of styles for properties or selectors • Use ‘@include’ to then apply without adding a class or copying and pasting • Again, changes happen in one place and then are updated • Pass some arguments if you are feelin’ lucky Sunday, October 23, 11
  • 9. Super Sass • Use ‘@import’ to pull in partial style sheets, or ‘partials’ i.e. _sassiest.sass • Short, sweet, imported directly • No file extension needed on the import • “any variables or mixins defined in @imported files are available to the files that import them” - http://sass-lang.com Sunday, October 23, 11
  • 10. Get Sass for Yourself • Install Ruby • Install Sass gem -> gem install sass • Start your compiler -> sass --watch style.scss:style.css • Write away! Sunday, October 23, 11
  • 11. Compass • CSS authoring framework • Use SCSS or Sass • Runs on Ruby too • Don’t write Sass without it -> gem install compass Sunday, October 23, 11
  • 12. Compass Core • Save yourself some time, pre-written • CSS3 gold • Common typography styles? No sweat. • Compass core utilities • Can also opt to import the Blueprint project, which is fully supported Sunday, October 23, 11
  • 13. @import “compass/css3” • Use kick-sass CSS3 properties and let compass handle the cross-browser code Appearance Box Shadow Inline Block Background Clip Box Sizing Opacity Background Origin Columns Text Shadow Background Size Font Face Transform Border Radius Gradient Transition Box Images Sunday, October 23, 11
  • 14. @import “compass/ typography” • style up lists, links, text styling, and vertical rhythm links horizontal lists text replacement hover Link inline-block lists vertical rhythm link colors inline lists baselines unstyled links ellipsis font size lists force wrap line height bullets no wrap Sunday, October 23, 11
  • 15. @import “compass/ utilities” • make colors magical, fix floats, pre-hack specific browsers, make sprites easy and make styling tables smart colors minimums table striping clearfix resets table borders floats tags table scaffolding hacks sprites Sunday, October 23, 11
  • 16. Susy! • “A simple grid system that is fully customized to your markup, your grid, your designs, the way you want them.” - @eriiicam the creator • gem install compass-susy-plugin Sunday, October 23, 11
  • 17. Set-up • Define variables for: • number of columns in grid • column width • gutter width (space between columns) • side-gutter width Sunday, October 23, 11
  • 18. Grids, Grids, Grids • “fluid on the inside & elastic on the outside” - @eriiicam • Units: use percentages for a fluid grid and pixels for a fixed grid • Mixins: use ‘full’ to span the full width and ‘columns’ to declare element widths within the container Sunday, October 23, 11
  • 19. How to make it work 1. It’s just CSS 2. Compiling and committing: formats and using a version control system 3. Teamwork: #teamSass and using Sass as a Team Sunday, October 23, 11
  • 20. 1. It’s just CSS • Don’t get carried away • Check what your css looks like if your changes aren’t showing • Use CSS best practices, only faster • Use Compass to generate common CSS • Remember: Clean Code is Good Code Sunday, October 23, 11
  • 21. 2. Compiling & Committing • Be careful when using FireSass • Watch your compiling stream for errors and deprecations • The difference between compass compile & compass watch • Turn of comments, re-compile, commit with... Git Sunday, October 23, 11
  • 22. 3. Teamwork • Join team Sass, but don’t become a sass- hole to your team • Use arguments, but don’t argue over syntax, they work together! • Pro-tip: Committing JUST the Sass/Scss and compiling CSS on the server, environment-permitting Sunday, October 23, 11
  • 23. References & Resources • Sass: http://sass-lang.com/ • Compass: http://compass-style.org/ • Susy: http://susy.oddbird.net/ • The Sass Way: http://thesassway.com • On twitter: @thesassway & #teamSass Sunday, October 23, 11
  • 24. Thanks! • dead_arm on drupal.org and twitter Sunday, October 23, 11