SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
Sass & Compass
    Presented by: Ethan Gardner
What is Sass?
• CSS preprocessor written in Ruby
• Compiles to regular CSS
• Adds many helpful features to CSS…




Official Documentation:
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html
What is Compass?
• An extension of Sass
• Contains many CSS3 helpers used in
  modern web development.
• Adds many helpful features to CSS…



Official Documentation:
http://compass-style.org/reference/compass/
Retrofitting Compass to
            Existing Project
$ compass create --bare --sass-
dir "sass" --css-dir "." --
javascripts-dir "assets/scripts"
--images-dir "images"



Installation:
http://compass-style.org/install/
After Running…
Changing Options
To change these options after Compass
has been added to the project, you can
always edit the “config.rb” file
Starting Compass
Navigate to the directory that contains the
“config.rb” file in the command line and
type:

compass watch
Variables
• Common values can assigned to
  variables for use throughout a project.
• One of the best features of Sass
• $variable-name: value;
Using Variables
SCSS                                CSS output
$accent-color:#17CF57;              h1 {
                                      color: #17cf57;
h1 {                                }
  color:$accent-color;
}                                   fieldset {
                                      border: 1px solid #17cf57;
fieldset {
                                    }
  border:1px solid $accent-color;
}
                                    caption {
caption {
                                      background: #17cf57;
  background:$accent-color;           color: #fff;
  color:#fff;                       }
}
Working with Variables
• Assign at the top of the file or in an
  external file
• Great for consistency
• Benefits are apparent with larger files
Nested Rules
Rules can be nested to add specificity to a
selector.
Adding Specificity with Nested
            Rules
SCSS                       CSS output
ul {                       ul {
  list-style-type: disc;     list-style-type: disc;
  li {                     }
    padding:10px;          ul li {
  }                          padding: 10px;
}                          }
Ampersands in Nested Rules
When nested rules are used, an
ampersand adds properties to a child
selector and is useful for pseudo classes
like :hover.
Ampersands in Nested Rules
SCSS                             CSS output
a {                              a {
  text-decoration:none;            text-decoration: none;
  &:hover {                      }
    text-decoration:underline;   a:hover {
  }                                text-decoration: underline;
}                                }
Ampersands in Nested Rules
           (cont’d)
SCSS                    CSS output
p {                     p {
  font-size:14px;         font-size: 14px;
  &.error {             }
    color:#f00;         p.error {
    font-weight:bold;     color: #f00;
  }                       font-weight: bold;
}                       }
Did you catch the difference?
Notice there is no space between p and
.error in the CSS from the previous
example.
If you WANTED a space…
SCSS                    CSS output
p {                     p {
  font-size:14px;         font-size: 14px;
  .error {              }
    color:#f00;         p .error {
    font-weight:bold;     color: #f00;
  }                       font-weight: bold;
}                       }
Multiple Nesting
You don’t have to stop at one level of
nesting. Multiple levels of nesting can be
VERY powerful.
Multiple Nesting
SCSS                        CSS output
.tablesorter {              .tablesorter {
  border:1px solid #000;      border: 1px solid #000;
  thead {                   }
    background:#000;        .tablesorter thead {
    color:#fff;               background: #000;
    th {                      color: #fff;
       text-align:center;   }
    }                       .tablesorter thead th {
  }                           text-align: center;
  tr {                      }
    background:#fff;        .tablesorter tr {
  }                           background: #fff;
}                           }
@extend
@extend uses the properties of a selector
as the foundation for another selector
@extend
SCSS                                   CSS output
.session {                             .session, .keynote, .company {
  padding-left:8px;                      padding-left: 8px;
  padding-right:20px;
                                         padding-right: 20px;
  background-repeat:repeat-y;
}                                        background-repeat: repeat-y;
                                       }
.keynote {
  @extend .session;                    .keynote {
    background-image:url(cat-1.png);
}                                          background-image: url(cat-1.png);
                                       }
.company {
  @extend .session;                    .company {
    background-image:url(cat-2.png);
                                           background-image: url(cat-2.png);
}
                                       }
@import
Properties can be imported from other
Sass files.
Tips for using @import
• Put common properties in external file
• Different than using @import in CSS
• Imported files should begin with an “_”
@import
SCSS                            CSS output
// Loads Compass CSS3 helpers   /*
@import 'compass/css3';         Loads all helpers from Compass’
                                CSS3 modules and makes it
// Loads user defined files     available to the rest of our
                                project.
@import 'base';
@import 'reset';
                                Imports the “_base.scss” file
                                and then imports the
                                “_reset.scss” file .
                                */
@mixin
• Small piece of code that is used to build
  something larger
• Define once and use anywhere
• Can accept arguments and parameters
• Used via the @include keyword
@mixin – User Defined
SCSS                                CSS output
                                    #article {
$border-color:#efefef;
                                      border: 1px solid #efefef;
@mixin content-area {
  border:1px solid $border-color;     padding: 10px 2%;
  padding:10px 2%;                    float: left;
}
                                      width: 60%;
#article {                          }
  @include content-area;
  float:left;
  width:60%;
}                                   #aside {
                                      border: 1px solid #efefef;
#aside {
  @include content-area;              padding: 10px 2%;
  float:right;                        float: right;
  width:30%;
}                                     width: 30%;
                                    }
Compass @mixin
Compass provides mixins for common
CSS3 features like gradients, box-shadow,
text-shadow, etc.
@mixin – Compass
SCSS
#article {
  @include background-image(linear-gradient(#dedede, #fff));
  color:$content-text-color;
  @include content-area; // user defined from previous example
  @include box-shadow;
  @include text-shadow;
  float:left;
  width:60%;
}
@mixin – Compass (cont’d)
CSS output
#article {
  background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-
stop(0%, #dedede), color-stop(100%, #ffffff));
  background-image: -webkit-linear-gradient(#dedede, #ffffff);
  background-image: -moz-linear-gradient(#dedede, #ffffff);
  background-image: -o-linear-gradient(#dedede, #ffffff);
  background-image: -ms-linear-gradient(#dedede, #ffffff);
  background-image: linear-gradient(#dedede, #ffffff);
  color: black;
  border: 1px solid #efefef;
  padding: 10px 2%;
  -webkit-box-shadow: 0px 0px 5px #333333;
  -moz-box-shadow: 0px 0px 5px #333333;
  box-shadow: 0px 0px 5px #333333;
  text-shadow: #efefef 0px 0px 1px;
  float: left;
  width: 60%;
}

Mais conteúdo relacionado

Mais procurados

LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageKatsunori Tanaka
 
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
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyArcbees
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyjdramaix
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with SassRob Friesel
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sassHuiyi Yan
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
Sass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVSass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVDirk Ginader
 

Mais procurados (20)

LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
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
 
Sass, Compass
Sass, CompassSass, Compass
Sass, Compass
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
 
Compass/Sass
Compass/SassCompass/Sass
Compass/Sass
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Sass
SassSass
Sass
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sass
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Less
LessLess
Less
 
Css to-scss
Css to-scssCss to-scss
Css to-scss
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
Sass
SassSass
Sass
 
Sass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IVSass, Compass and the new tools - Open Web Camp IV
Sass, Compass and the new tools - Open Web Camp IV
 

Destaque (8)

Compass n Sass
Compass n SassCompass n Sass
Compass n Sass
 
пол.
пол.пол.
пол.
 
Pedras naturais e silestone
Pedras naturais e silestonePedras naturais e silestone
Pedras naturais e silestone
 
Fontes de água em Salvador
Fontes de água em Salvador Fontes de água em Salvador
Fontes de água em Salvador
 
сюжетно ролевые игры3
сюжетно ролевые игры3сюжетно ролевые игры3
сюжетно ролевые игры3
 
Social Media and Privacy
Social Media and PrivacySocial Media and Privacy
Social Media and Privacy
 
Debugging with Firebug
Debugging with Firebug Debugging with Firebug
Debugging with Firebug
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 

Semelhante a Sass and Compass - Getting Started

Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob Davarnia
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSSSayanee Basu
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quickBilly Shih
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Tahmina Khatoon
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & CompassAndreas Dantz
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustKyle Adams
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Anam Hossain
 
Save time by using SASS/SCSS
Save time by using SASS/SCSSSave time by using SASS/SCSS
Save time by using SASS/SCSSBerit Hlubek
 
Agile CSS development with Compass and Sass
Agile CSS development with Compass and SassAgile CSS development with Compass and Sass
Agile CSS development with Compass and SassAndrea Verlicchi
 
HTML&CSS 5 - Intermediate CSS (2/2)
HTML&CSS 5 - Intermediate CSS (2/2)HTML&CSS 5 - Intermediate CSS (2/2)
HTML&CSS 5 - Intermediate CSS (2/2)Dinis Correia
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3 Wynn Netherland
 

Semelhante a Sass and Compass - Getting Started (20)

Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quick
 
Less css
Less cssLess css
Less css
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
PostCss
PostCssPostCss
PostCss
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
Less & Sass
Less & SassLess & Sass
Less & Sass
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
 
CSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie DustCSS3 is Not Magic Pixie Dust
CSS3 is Not Magic Pixie Dust
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
 
Save time by using SASS/SCSS
Save time by using SASS/SCSSSave time by using SASS/SCSS
Save time by using SASS/SCSS
 
Agile CSS development with Compass and Sass
Agile CSS development with Compass and SassAgile CSS development with Compass and Sass
Agile CSS development with Compass and Sass
 
HTML&CSS 5 - Intermediate CSS (2/2)
HTML&CSS 5 - Intermediate CSS (2/2)HTML&CSS 5 - Intermediate CSS (2/2)
HTML&CSS 5 - Intermediate CSS (2/2)
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 

Último

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 

Último (20)

Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
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
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
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
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 

Sass and Compass - Getting Started

  • 1. Sass & Compass Presented by: Ethan Gardner
  • 2. What is Sass? • CSS preprocessor written in Ruby • Compiles to regular CSS • Adds many helpful features to CSS… Official Documentation: http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html
  • 3. What is Compass? • An extension of Sass • Contains many CSS3 helpers used in modern web development. • Adds many helpful features to CSS… Official Documentation: http://compass-style.org/reference/compass/
  • 4. Retrofitting Compass to Existing Project $ compass create --bare --sass- dir "sass" --css-dir "." -- javascripts-dir "assets/scripts" --images-dir "images" Installation: http://compass-style.org/install/
  • 6. Changing Options To change these options after Compass has been added to the project, you can always edit the “config.rb” file
  • 7. Starting Compass Navigate to the directory that contains the “config.rb” file in the command line and type: compass watch
  • 8. Variables • Common values can assigned to variables for use throughout a project. • One of the best features of Sass • $variable-name: value;
  • 9. Using Variables SCSS CSS output $accent-color:#17CF57; h1 { color: #17cf57; h1 { } color:$accent-color; } fieldset { border: 1px solid #17cf57; fieldset { } border:1px solid $accent-color; } caption { caption { background: #17cf57; background:$accent-color; color: #fff; color:#fff; } }
  • 10. Working with Variables • Assign at the top of the file or in an external file • Great for consistency • Benefits are apparent with larger files
  • 11. Nested Rules Rules can be nested to add specificity to a selector.
  • 12. Adding Specificity with Nested Rules SCSS CSS output ul { ul { list-style-type: disc; list-style-type: disc; li { } padding:10px; ul li { } padding: 10px; } }
  • 13. Ampersands in Nested Rules When nested rules are used, an ampersand adds properties to a child selector and is useful for pseudo classes like :hover.
  • 14. Ampersands in Nested Rules SCSS CSS output a { a { text-decoration:none; text-decoration: none; &:hover { } text-decoration:underline; a:hover { } text-decoration: underline; } }
  • 15. Ampersands in Nested Rules (cont’d) SCSS CSS output p { p { font-size:14px; font-size: 14px; &.error { } color:#f00; p.error { font-weight:bold; color: #f00; } font-weight: bold; } }
  • 16. Did you catch the difference? Notice there is no space between p and .error in the CSS from the previous example.
  • 17. If you WANTED a space… SCSS CSS output p { p { font-size:14px; font-size: 14px; .error { } color:#f00; p .error { font-weight:bold; color: #f00; } font-weight: bold; } }
  • 18. Multiple Nesting You don’t have to stop at one level of nesting. Multiple levels of nesting can be VERY powerful.
  • 19. Multiple Nesting SCSS CSS output .tablesorter { .tablesorter { border:1px solid #000; border: 1px solid #000; thead { } background:#000; .tablesorter thead { color:#fff; background: #000; th { color: #fff; text-align:center; } } .tablesorter thead th { } text-align: center; tr { } background:#fff; .tablesorter tr { } background: #fff; } }
  • 20. @extend @extend uses the properties of a selector as the foundation for another selector
  • 21. @extend SCSS CSS output .session { .session, .keynote, .company { padding-left:8px; padding-left: 8px; padding-right:20px; padding-right: 20px; background-repeat:repeat-y; } background-repeat: repeat-y; } .keynote { @extend .session; .keynote { background-image:url(cat-1.png); } background-image: url(cat-1.png); } .company { @extend .session; .company { background-image:url(cat-2.png); background-image: url(cat-2.png); } }
  • 22. @import Properties can be imported from other Sass files.
  • 23. Tips for using @import • Put common properties in external file • Different than using @import in CSS • Imported files should begin with an “_”
  • 24. @import SCSS CSS output // Loads Compass CSS3 helpers /* @import 'compass/css3'; Loads all helpers from Compass’ CSS3 modules and makes it // Loads user defined files available to the rest of our project. @import 'base'; @import 'reset'; Imports the “_base.scss” file and then imports the “_reset.scss” file . */
  • 25. @mixin • Small piece of code that is used to build something larger • Define once and use anywhere • Can accept arguments and parameters • Used via the @include keyword
  • 26. @mixin – User Defined SCSS CSS output #article { $border-color:#efefef; border: 1px solid #efefef; @mixin content-area { border:1px solid $border-color; padding: 10px 2%; padding:10px 2%; float: left; } width: 60%; #article { } @include content-area; float:left; width:60%; } #aside { border: 1px solid #efefef; #aside { @include content-area; padding: 10px 2%; float:right; float: right; width:30%; } width: 30%; }
  • 27. Compass @mixin Compass provides mixins for common CSS3 features like gradients, box-shadow, text-shadow, etc.
  • 28. @mixin – Compass SCSS #article { @include background-image(linear-gradient(#dedede, #fff)); color:$content-text-color; @include content-area; // user defined from previous example @include box-shadow; @include text-shadow; float:left; width:60%; }
  • 29. @mixin – Compass (cont’d) CSS output #article { background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color- stop(0%, #dedede), color-stop(100%, #ffffff)); background-image: -webkit-linear-gradient(#dedede, #ffffff); background-image: -moz-linear-gradient(#dedede, #ffffff); background-image: -o-linear-gradient(#dedede, #ffffff); background-image: -ms-linear-gradient(#dedede, #ffffff); background-image: linear-gradient(#dedede, #ffffff); color: black; border: 1px solid #efefef; padding: 10px 2%; -webkit-box-shadow: 0px 0px 5px #333333; -moz-box-shadow: 0px 0px 5px #333333; box-shadow: 0px 0px 5px #333333; text-shadow: #efefef 0px 0px 1px; float: left; width: 60%; }