SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
DRY cross-browser CSS with SASS




Saturday, October 31, 2009
Speaker.new({
                    :name            =>   "Wes Oldenbeuving",
                    :twitter         =>   "@Narnach",
                    :rubyist_since   =>   "Early 2006",
                    :works_as        =>   "Freelance Rubyist",
                    :code_at         =>   "github.com/Narnach"
                 })




Saturday, October 31, 2009
Web development
                               (With Ruby on Rails)




Saturday, October 31, 2009
DRY:
                   Don’t Repeat Yourself




                             http://www.flickr.com/photos/cmgramse/2301230228/

Saturday, October 31, 2009
HTML
                       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                       <html>
                         <head>
                           <title>FooBar corp.</title>
                         </head>
                         <body>
                           <div id='header'>
                              <h1>Welcome to FooBar corp.</h1>
                           </div>
                           <div id='content'>
                              <!-- Content goes here -->
                           </div>
                           <div id='footer'>Copyright blah blah</div>
                         </body>
                       </html>




Saturday, October 31, 2009
HAML
                       <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                       <html>
                         <head>    !!! strict
                           <title>FooBar corp.</title>
                                   %html
                         </head>     %head
                         <body>        %title FooBar corp.
                           <div id='header'>
                                     %body
                              <h1>Welcome to FooBar corp.</h1>
                                       #header
                           </div>        %h1 Welcome to FooBar corp.
                           <div id='content'>
                                       #content
                              <!-- Content goes here --> here
                                         / Content goes
                           </div>      #footer Copyright blah blah
                           <div id='footer'>Copyright blah blah</div>
                         </body>
                       </html>




Saturday, October 31, 2009
CSS
                    #linkList ul {
                      margin: 0;
                      padding: 0; }
                    #linkList li {
                      line-height: 2.5em;
                      background: transparent url(cr1.gif) no-repeat top center;
                      display: block;
                      padding-top: 5px;
                      margin-bottom: 5px;
                      list-style-type: none; }
                      #linkList li a:link {
                        color: #988F5E; }
                      #linkList li a:visited {
                        color: #B3AE94; }




Saturday, October 31, 2009
SASS
  #linkList ul {
    margin: 0;
    padding: 0; }
  #linkList li {
    line-height: 2.5em;
    background: transparent url(cr1.gif) no-repeat top center;
                        #linkList
    display: block;       ul
    padding-top: 5px;        :margin 0
    margin-bottom: 5px;      :padding 0
    list-style-type: none; }
                          li
    #linkList li a:link { :line-height 2.5em
      color: #988F5E; }      :background transparent url(cr1.gif) no-repeat top center
    #linkList li a:visited { :display block
      color: #B3AE94; }      :padding-top 5px
                             :margin-bottom 5px
                             :list-style-type none
                             a
                               &:link
                                 :color #988F5E
                               &:visited
                                 :color #B3AE94


Saturday, October 31, 2009
Nesting

            #content                     #content {
              :border                      border-top: 1px solid red;
                :top 1px solid red         border-left: 2px solid green;
                :left 2px solid green      border-right: 3px dotted blue;
                :right 3px dotted blue     border-bottom: none;
                :bottom none             }




Saturday, October 31, 2009
Variables
            // SASS                      /* CSS */

            !blue = #3bbfce              .content_navigation {
            !margin = 16px                 border-color: #3bbfce;
                                           color: #2aaebd; }
            .content_navigation
              :border-color = !blue      .border {
              :color = !blue - #111        padding: 8px;
                                           margin: 8px;
            .border                        border-color: #3bbfce; }
              :padding = !margin / 2
              :margin = !margin / 2
              :border-color = !blue




Saturday, October 31, 2009
Mixins
            // Sass                            /* CSS */

            =table-scaffolding                 #data {
              th                                 float: left;
                 :text-align center              margin-left: 10px;
                 :font-weight bold             }
              td, th                           #data th {
                 :padding 2px                    text-align: center;
                                                 font-weight: bold;
            =left(!dist)                       }
              :float left                      #data td, #data th {
              :margin-left = !dist               padding: 2px;
                                               }
            #data
              +left(10px)
              +table-scaffolding




Saturday, October 31, 2009
Output style: nested

                             sass -t nested mixins.sass
                                 #data {
                                   float: left;
                                   margin-left: 10px; }
                                   #data th {
                                     text-align: center;
                                     font-weight: bold; }
                                   #data td, #data th {
                                     padding: 2px; }




Saturday, October 31, 2009
Output style: expanded

                             sass -t expanded mixins.sass
                                   #data {
                                     float: left;
                                     margin-left: 10px;
                                   }
                                   #data th {
                                     text-align: center;
                                     font-weight: bold;
                                   }
                                   #data td, #data th {
                                     padding: 2px;
                                   }




Saturday, October 31, 2009
Output style: compact

                                   sass -t compact mixins.sass
                             #data { float: left; margin-left: 10px; }
                             #data th { text-align: center; font-weight: bold; }
                             #data td, #data th { padding: 2px; }




Saturday, October 31, 2009
Output style: compressed

                             sass -t compressed mixins.sass
                #data{float:left;margin-left:10px}#data th{text-align:center;font-
                weight:bold}#data td,#data th{padding:2px}




Saturday, October 31, 2009
Cross-browser SASS
                          examples




                             http://www.nurweb.biz/?p=471

Saturday, October 31, 2009
Rounded borders

                     // Create rounded borders in all browsers that support them
                     =rounded_borders(!color, !width = 5px, !rounding = 5px)
                       :-moz-border-radius = !rounding !rounding
                       :-webkit-border-radius = !rounding !rounding
                       :-khtml-border-radius = !rounding !rounding
                       :-o-border-radius = !rounding !rounding
                       :border-radius = !rounding !rounding
                       :border = !width !color "solid"

                     #header
                       +rounded_borders(green, 3px)




Saturday, October 31, 2009
Opacity

     =opacity(!value)
       :opacity = !value
       :-ms-filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=#{!value*100})"
       :filter = "alpha(opacity=#{!value * 100})"

     #content
       +opacity(0.9)




Saturday, October 31, 2009
Text-shadow

 // Note: This one requires some work to get the Direction working properly for IE.
 // Usage example: +text_shadow(#333, 1px, 1px, 1)

 =text_shadow(!color, !x, !y, !blur)
   :text-shadow = !color !x !y "#{!blur}px"
   :-ms-filter = "progid:DXImageTransform.Microsoft.Shadow(Color=#{!color},Direction=135,Strength=#{!blur})"




Saturday, October 31, 2009
Getting started with
                         SASS in Rails
                   run: gem install haml
                   in environment.rb: add config.gem ‘haml’
                   create public/stylesheets/sass/style.sass
                   require ‘style.css’ in your layout
                   script/server




Saturday, October 31, 2009
Less CSS, a SASS alternative

                   A CSS superset.
                   All of the cool SASS features, but with
                   semicolons and curly braces.
                   http://lesscss.org/




Saturday, October 31, 2009
Compass, a SASS
                               framework
                   SASS mixins to help with CSS frameworks like
                   Blueprint, YUI and 960.gs
                   SASS mixins that solve common problems, like
                   resetting the stylesheet and horizontal lists.
                   http://wiki.github.com/chriseppstein/compass




Saturday, October 31, 2009
Where to get SASS
                   Install: gem install haml
                   Website: http://sass-lang.com
                   Develop: http://github.com/nex3/haml
                   Also check out: http://haml-lang.com


                   Community plug: http://dev-groups.org


Saturday, October 31, 2009

Contenu connexe

Tendances

Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesDinu Suman
 
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
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With SassThomas Reynolds
 
Getting Plone Ready For The Prom
Getting Plone Ready For The PromGetting Plone Ready For The Prom
Getting Plone Ready For The PromClayton Parker
 
Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Matt Puchlerz
 
The Future Of CSS
The Future Of CSSThe Future Of CSS
The Future Of CSSAndy Budd
 
Class 2 handout css exercises (2)
Class 2 handout css exercises (2)Class 2 handout css exercises (2)
Class 2 handout css exercises (2)Erin M. Kidwell
 

Tendances (11)

Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 
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)
 
The Future of CSS
The Future of CSSThe Future of CSS
The Future of CSS
 
Simplifying CSS With Sass
Simplifying CSS With SassSimplifying CSS With Sass
Simplifying CSS With Sass
 
Getting Plone Ready For The Prom
Getting Plone Ready For The PromGetting Plone Ready For The Prom
Getting Plone Ready For The Prom
 
Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]Organizing & Simplifying CSS [with Sass]
Organizing & Simplifying CSS [with Sass]
 
LESS
LESSLESS
LESS
 
The Future Of CSS
The Future Of CSSThe Future Of CSS
The Future Of CSS
 
Class 2 handout css exercises (2)
Class 2 handout css exercises (2)Class 2 handout css exercises (2)
Class 2 handout css exercises (2)
 
lect9
lect9lect9
lect9
 
Theme04
Theme04Theme04
Theme04
 

Similaire à DRY cross-browser CSS with SASS

Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3 Wynn Netherland
 
Finding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with CompassFinding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with CompassClaudina Sarahe
 
Introdução a CSS
Introdução a CSS Introdução a CSS
Introdução a CSS Tiago Santos
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperWynn Netherland
 
Learn CSS From Scratch
Learn CSS From ScratchLearn CSS From Scratch
Learn CSS From Scratchecobold
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopShoshi Roberts
 
Haml and Sass Introduction
Haml and Sass IntroductionHaml and Sass Introduction
Haml and Sass IntroductionEthan Gunderson
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTMLAmit Tyagi
 
A Primer on HTML 5 - By Nick Armstrong
A Primer on HTML 5 - By Nick ArmstrongA Primer on HTML 5 - By Nick Armstrong
A Primer on HTML 5 - By Nick ArmstrongNick Armstrong
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
css-note.pptx
css-note.pptxcss-note.pptx
css-note.pptxSamay16
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 

Similaire à DRY cross-browser CSS with SASS (20)

Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
Finding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with CompassFinding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with Compass
 
Introdução a CSS
Introdução a CSS Introdução a CSS
Introdução a CSS
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
CSS3 ...in 3D!
CSS3 ...in 3D!CSS3 ...in 3D!
CSS3 ...in 3D!
 
CSS and Layout
CSS and LayoutCSS and Layout
CSS and Layout
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Learn CSS From Scratch
Learn CSS From ScratchLearn CSS From Scratch
Learn CSS From Scratch
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Css1
Css1Css1
Css1
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 Workshop
 
Haml and Sass Introduction
Haml and Sass IntroductionHaml and Sass Introduction
Haml and Sass Introduction
 
Introduction to HTML
Introduction to HTMLIntroduction to HTML
Introduction to HTML
 
A Primer on HTML 5 - By Nick Armstrong
A Primer on HTML 5 - By Nick ArmstrongA Primer on HTML 5 - By Nick Armstrong
A Primer on HTML 5 - By Nick Armstrong
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
DotNetNuke World CSS3
DotNetNuke World CSS3DotNetNuke World CSS3
DotNetNuke World CSS3
 
css-note.pptx
css-note.pptxcss-note.pptx
css-note.pptx
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 

Dernier

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 

Dernier (20)

What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 

DRY cross-browser CSS with SASS

  • 1. DRY cross-browser CSS with SASS Saturday, October 31, 2009
  • 2. Speaker.new({ :name => "Wes Oldenbeuving", :twitter => "@Narnach", :rubyist_since => "Early 2006", :works_as => "Freelance Rubyist", :code_at => "github.com/Narnach" }) Saturday, October 31, 2009
  • 3. Web development (With Ruby on Rails) Saturday, October 31, 2009
  • 4. DRY: Don’t Repeat Yourself http://www.flickr.com/photos/cmgramse/2301230228/ Saturday, October 31, 2009
  • 5. HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>FooBar corp.</title> </head> <body> <div id='header'> <h1>Welcome to FooBar corp.</h1> </div> <div id='content'> <!-- Content goes here --> </div> <div id='footer'>Copyright blah blah</div> </body> </html> Saturday, October 31, 2009
  • 6. HAML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> !!! strict <title>FooBar corp.</title> %html </head> %head <body> %title FooBar corp. <div id='header'> %body <h1>Welcome to FooBar corp.</h1> #header </div> %h1 Welcome to FooBar corp. <div id='content'> #content <!-- Content goes here --> here / Content goes </div> #footer Copyright blah blah <div id='footer'>Copyright blah blah</div> </body> </html> Saturday, October 31, 2009
  • 7. CSS #linkList ul { margin: 0; padding: 0; } #linkList li { line-height: 2.5em; background: transparent url(cr1.gif) no-repeat top center; display: block; padding-top: 5px; margin-bottom: 5px; list-style-type: none; } #linkList li a:link { color: #988F5E; } #linkList li a:visited { color: #B3AE94; } Saturday, October 31, 2009
  • 8. SASS #linkList ul { margin: 0; padding: 0; } #linkList li { line-height: 2.5em; background: transparent url(cr1.gif) no-repeat top center; #linkList display: block; ul padding-top: 5px; :margin 0 margin-bottom: 5px; :padding 0 list-style-type: none; } li #linkList li a:link { :line-height 2.5em color: #988F5E; } :background transparent url(cr1.gif) no-repeat top center #linkList li a:visited { :display block color: #B3AE94; } :padding-top 5px :margin-bottom 5px :list-style-type none a &:link :color #988F5E &:visited :color #B3AE94 Saturday, October 31, 2009
  • 9. Nesting #content #content { :border border-top: 1px solid red; :top 1px solid red border-left: 2px solid green; :left 2px solid green border-right: 3px dotted blue; :right 3px dotted blue border-bottom: none; :bottom none } Saturday, October 31, 2009
  • 10. Variables // SASS /* CSS */ !blue = #3bbfce .content_navigation { !margin = 16px border-color: #3bbfce; color: #2aaebd; } .content_navigation :border-color = !blue .border { :color = !blue - #111 padding: 8px; margin: 8px; .border border-color: #3bbfce; } :padding = !margin / 2 :margin = !margin / 2 :border-color = !blue Saturday, October 31, 2009
  • 11. Mixins // Sass /* CSS */ =table-scaffolding #data { th float: left; :text-align center margin-left: 10px; :font-weight bold } td, th #data th { :padding 2px text-align: center; font-weight: bold; =left(!dist) } :float left #data td, #data th { :margin-left = !dist padding: 2px; } #data +left(10px) +table-scaffolding Saturday, October 31, 2009
  • 12. Output style: nested sass -t nested mixins.sass #data { float: left; margin-left: 10px; } #data th { text-align: center; font-weight: bold; } #data td, #data th { padding: 2px; } Saturday, October 31, 2009
  • 13. Output style: expanded sass -t expanded mixins.sass #data { float: left; margin-left: 10px; } #data th { text-align: center; font-weight: bold; } #data td, #data th { padding: 2px; } Saturday, October 31, 2009
  • 14. Output style: compact sass -t compact mixins.sass #data { float: left; margin-left: 10px; } #data th { text-align: center; font-weight: bold; } #data td, #data th { padding: 2px; } Saturday, October 31, 2009
  • 15. Output style: compressed sass -t compressed mixins.sass #data{float:left;margin-left:10px}#data th{text-align:center;font- weight:bold}#data td,#data th{padding:2px} Saturday, October 31, 2009
  • 16. Cross-browser SASS examples http://www.nurweb.biz/?p=471 Saturday, October 31, 2009
  • 17. Rounded borders // Create rounded borders in all browsers that support them =rounded_borders(!color, !width = 5px, !rounding = 5px) :-moz-border-radius = !rounding !rounding :-webkit-border-radius = !rounding !rounding :-khtml-border-radius = !rounding !rounding :-o-border-radius = !rounding !rounding :border-radius = !rounding !rounding :border = !width !color "solid" #header +rounded_borders(green, 3px) Saturday, October 31, 2009
  • 18. Opacity =opacity(!value) :opacity = !value :-ms-filter = "progid:DXImageTransform.Microsoft.Alpha(Opacity=#{!value*100})" :filter = "alpha(opacity=#{!value * 100})" #content +opacity(0.9) Saturday, October 31, 2009
  • 19. Text-shadow // Note: This one requires some work to get the Direction working properly for IE. // Usage example: +text_shadow(#333, 1px, 1px, 1) =text_shadow(!color, !x, !y, !blur) :text-shadow = !color !x !y "#{!blur}px" :-ms-filter = "progid:DXImageTransform.Microsoft.Shadow(Color=#{!color},Direction=135,Strength=#{!blur})" Saturday, October 31, 2009
  • 20. Getting started with SASS in Rails run: gem install haml in environment.rb: add config.gem ‘haml’ create public/stylesheets/sass/style.sass require ‘style.css’ in your layout script/server Saturday, October 31, 2009
  • 21. Less CSS, a SASS alternative A CSS superset. All of the cool SASS features, but with semicolons and curly braces. http://lesscss.org/ Saturday, October 31, 2009
  • 22. Compass, a SASS framework SASS mixins to help with CSS frameworks like Blueprint, YUI and 960.gs SASS mixins that solve common problems, like resetting the stylesheet and horizontal lists. http://wiki.github.com/chriseppstein/compass Saturday, October 31, 2009
  • 23. Where to get SASS Install: gem install haml Website: http://sass-lang.com Develop: http://github.com/nex3/haml Also check out: http://haml-lang.com Community plug: http://dev-groups.org Saturday, October 31, 2009