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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
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...Drew Madelung
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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 2024Results
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Kürzlich hochgeladen (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
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...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

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