SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Modularization CSS with SASS
Yan Huiyi(Dean)
RPID, RealPlayer Cloud
RealNetworks, Inc.
SASS Syntax
Save as .sass
$font-base-size: 16px
$link-color: #ff0000
body
font: $font-base-size
a
color: $link-color
Save as .scss
$font-base-size: 16px;
$link-color: #ff0000;
body {
font: $font-base-size;
}
a {
color: $link-color;
}
.sass use indent to interpret syntax(error-prone, if you are careless), we use SCSS syntax in OrderPath.
RealNetworks, Inc.2014/7/31 2
A tale of two syntax
Nested
.product-details {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 28em;
}
.product-details .fee-details {
height: 27.3em;
padding: 2em 1em;
background-color: #F2FAFF;
border: 1px solid #00A1FF;
}
.product-details .fee-details small {
font-size: 1em;
}
.product-details {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 28em;
.fee-details {
height : 27.3em;
padding : 2em 1em;
background-color: #F2FAFF;
border: 1px solid #00A1FF;
small {
font-size: calc-em(10px, 10px);
}
}
}
RealNetworks, Inc.2014/7/31 3
Referencing Parent Selectors: &
.form-control {
font-size: 14px;
color : #9f9f9f;
height: 38px;
&.error {
border: 1px solid #ed1c24;
}
}
.form-control {
font-size: 14px;
color: #9f9f9f;
height: 38px;
}
.form-control.error {
border: 1px solid #ed1c24;
}
a {
color: #9f9f9f;
text-decoration: none;
&:hover,
&:focus {
color: #9f9f9f;
text-decoration: underline;
}
a {
color: #9f9f9f;
text-decoration: none;
}
a:hover, a:focus {
color: #9f9f9f;
text-decoration: underline;
}
RealNetworks, Inc.2014/7/31 4
Extend
.cards {
background-image: url(cc_sprite.png);
background-repeat: no-repeat;
height: 34px;
width: 177px;
}
.jp .cards {
@extend .cards;
background-image: url(cc_sprite_retina.png);
}
.jp .cards {
background-image url(cc_sprite.png);
background-repeat: no-repeat;
height: 34px;
width: 177px;
}
.jp .cards {
background-image: url(cc_sprite_retina.png);
}
RealNetworks, Inc.2014/7/31 5
Media Queries
.first-name, .last-name {
width: 9.64286em;
@media only screen and (min-width: 321px) {
width: 15.35714em;
}
@media only screen and (min-width: 321px) and (max-
width: 360px) {
width: 10.92857em;
}
}
.first-name, .last-name {
width: 9.64286em;
}
@media only screen and (min-width: 321px) {
.first-name, .last-name {
width: 15.35714em;
}
}
@media only screen and (min-width: 321px) and (max-width: 360px) {
.first-name, .last-name {
width: 10.92857em;
}
}
RealNetworks, Inc.2014/7/31 6
Partials
A partial is simply a Sass file named with a leading underscore. You might name it something like _partial.scss. The
underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass
partials are used with the @import directive.
- sass-lang.com
_lightbox.scss
.lightbox {
position: relative;
background: #fff;
#close {
position: absolute;
right: 5px;
top: 5px;
}
}
.lightbox-outer {
padding: 2em 0;
z-index: 20;
}
billing.scss
@import "lightbox"
billing.css
.lightbox {
position: relative;
background: #fff;
}
.lightbox #close {
position: absolute;
right: 5px;
top: 5px;
}
.lightbox-outer {
padding: 2em 0;
z-index: 20;
}
RealNetworks, Inc.2014/7/31 7
Mixins
A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. You can even pass in
values to make your mixin more flexible.
- sass-lang.com
_misc.scss
@mixin centererie($width, $height, $top: 50%, $left: 50%) {
position: absolute;
top: $top;
left: $left;
margin-left: ($width / 2) * -1;
@if $top == 50% {
margin-top: ($width / 2) * -1;
}
}
billing.scss
.lightbox {
@include centererie(290px, 459px, 22px);
}
billing.css
.lightbox {
position: absolute;
top: 22px;
left: 50%;
margin-left: -145px;
}
RealNetworks, Inc.2014/7/31 8
Modularization Styles with Partials, Mixins
partials(code snippet reusable)
_common.scss
_buttons.scss
_custom_select.scss
_opacity_scss
…
mixins ( like functions, accept variables, params)
_alert.scss
_media-queries.scss
_clearfix.scss
_base.scss(@mixin desktop, @clearfix…)
…
billing.scss
@import “common”;
@import “buttons”;
@import “base”;
.container {
@include desktop {
@include clearfix();
}
}
RealNetworks, Inc.2014/7/31 9
SASS - install, compile and watch changes
1. install ruby
2. install sass gem
I. gem install sass
II. sass -v
3. compile scss into css
sass billing.scss billing.css
4. watch single files changes
sass –watch billing.scss:billing.css
5. watch folders changes
sass –watch stylesheets:dist/css
RealNetworks, Inc.2014/7/31 10
Output Style
2014/7/31 RealNetworks, Inc. 11
There’re four different output styles to set using –style options in command line. :nested, :expanded, :compact
and :compressed.
:compressed( in production)
.try-again,.tech-diff .try-again{font-size:2.4em;margin-bottom:3.5em}
:expanded(using in development/debug)
.try-again,.tech-diff .try-again{
font-size:2.4em;
margin-bottom:3.5em
}
More Features…
2014/7/31 RealNetworks, Inc. 12
conditional expressions(@if, @for), Interpolation, %placeholders, Functions
Learn more
7 Sass features you should be familiar with
Bootstrap-sass
Thanks!
RealNetworks, Inc.2014/7/31 13

Weitere ähnliche Inhalte

Ähnlich wie Modularization css with sass

Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageKatsunori Tanaka
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with SassSven Wolfermann
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)Folio3 Software
 
Sakai Meet MORPHEUS: Slides
Sakai Meet MORPHEUS: SlidesSakai Meet MORPHEUS: Slides
Sakai Meet MORPHEUS: Slidesalienresident
 
@Agawish creating a stunning ui with oracle adf faces, using sass
@Agawish   creating a stunning ui with oracle adf faces, using sass@Agawish   creating a stunning ui with oracle adf faces, using sass
@Agawish creating a stunning ui with oracle adf faces, using sassAmr Gawish
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSSSayanee Basu
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compassdrywallbmb
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsSanjoy Kr. Paul
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
Pacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSPacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSSteve Krueger
 

Ähnlich wie Modularization css with sass (20)

SASS Preprocessor
SASS PreprocessorSASS Preprocessor
SASS Preprocessor
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)An Introduction to CSS Preprocessors (SASS & LESS)
An Introduction to CSS Preprocessors (SASS & LESS)
 
Sakai Meet MORPHEUS: Slides
Sakai Meet MORPHEUS: SlidesSakai Meet MORPHEUS: Slides
Sakai Meet MORPHEUS: Slides
 
@Agawish creating a stunning ui with oracle adf faces, using sass
@Agawish   creating a stunning ui with oracle adf faces, using sass@Agawish   creating a stunning ui with oracle adf faces, using sass
@Agawish creating a stunning ui with oracle adf faces, using sass
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
 
CSS3
CSS3CSS3
CSS3
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
PostCss
PostCssPostCss
PostCss
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and Cons
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
SASS Lecture
SASS Lecture SASS Lecture
SASS Lecture
 
Pacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSPacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASS
 

Kürzlich hochgeladen

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
 
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
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
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
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 

Kürzlich hochgeladen (20)

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
 
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
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
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
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
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
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
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)
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 

Modularization css with sass

  • 1. Modularization CSS with SASS Yan Huiyi(Dean) RPID, RealPlayer Cloud RealNetworks, Inc.
  • 2. SASS Syntax Save as .sass $font-base-size: 16px $link-color: #ff0000 body font: $font-base-size a color: $link-color Save as .scss $font-base-size: 16px; $link-color: #ff0000; body { font: $font-base-size; } a { color: $link-color; } .sass use indent to interpret syntax(error-prone, if you are careless), we use SCSS syntax in OrderPath. RealNetworks, Inc.2014/7/31 2 A tale of two syntax
  • 3. Nested .product-details { display: block; margin-left: auto; margin-right: auto; max-width: 28em; } .product-details .fee-details { height: 27.3em; padding: 2em 1em; background-color: #F2FAFF; border: 1px solid #00A1FF; } .product-details .fee-details small { font-size: 1em; } .product-details { display: block; margin-left: auto; margin-right: auto; max-width: 28em; .fee-details { height : 27.3em; padding : 2em 1em; background-color: #F2FAFF; border: 1px solid #00A1FF; small { font-size: calc-em(10px, 10px); } } } RealNetworks, Inc.2014/7/31 3
  • 4. Referencing Parent Selectors: & .form-control { font-size: 14px; color : #9f9f9f; height: 38px; &.error { border: 1px solid #ed1c24; } } .form-control { font-size: 14px; color: #9f9f9f; height: 38px; } .form-control.error { border: 1px solid #ed1c24; } a { color: #9f9f9f; text-decoration: none; &:hover, &:focus { color: #9f9f9f; text-decoration: underline; } a { color: #9f9f9f; text-decoration: none; } a:hover, a:focus { color: #9f9f9f; text-decoration: underline; } RealNetworks, Inc.2014/7/31 4
  • 5. Extend .cards { background-image: url(cc_sprite.png); background-repeat: no-repeat; height: 34px; width: 177px; } .jp .cards { @extend .cards; background-image: url(cc_sprite_retina.png); } .jp .cards { background-image url(cc_sprite.png); background-repeat: no-repeat; height: 34px; width: 177px; } .jp .cards { background-image: url(cc_sprite_retina.png); } RealNetworks, Inc.2014/7/31 5
  • 6. Media Queries .first-name, .last-name { width: 9.64286em; @media only screen and (min-width: 321px) { width: 15.35714em; } @media only screen and (min-width: 321px) and (max- width: 360px) { width: 10.92857em; } } .first-name, .last-name { width: 9.64286em; } @media only screen and (min-width: 321px) { .first-name, .last-name { width: 15.35714em; } } @media only screen and (min-width: 321px) and (max-width: 360px) { .first-name, .last-name { width: 10.92857em; } } RealNetworks, Inc.2014/7/31 6
  • 7. Partials A partial is simply a Sass file named with a leading underscore. You might name it something like _partial.scss. The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the @import directive. - sass-lang.com _lightbox.scss .lightbox { position: relative; background: #fff; #close { position: absolute; right: 5px; top: 5px; } } .lightbox-outer { padding: 2em 0; z-index: 20; } billing.scss @import "lightbox" billing.css .lightbox { position: relative; background: #fff; } .lightbox #close { position: absolute; right: 5px; top: 5px; } .lightbox-outer { padding: 2em 0; z-index: 20; } RealNetworks, Inc.2014/7/31 7
  • 8. Mixins A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. You can even pass in values to make your mixin more flexible. - sass-lang.com _misc.scss @mixin centererie($width, $height, $top: 50%, $left: 50%) { position: absolute; top: $top; left: $left; margin-left: ($width / 2) * -1; @if $top == 50% { margin-top: ($width / 2) * -1; } } billing.scss .lightbox { @include centererie(290px, 459px, 22px); } billing.css .lightbox { position: absolute; top: 22px; left: 50%; margin-left: -145px; } RealNetworks, Inc.2014/7/31 8
  • 9. Modularization Styles with Partials, Mixins partials(code snippet reusable) _common.scss _buttons.scss _custom_select.scss _opacity_scss … mixins ( like functions, accept variables, params) _alert.scss _media-queries.scss _clearfix.scss _base.scss(@mixin desktop, @clearfix…) … billing.scss @import “common”; @import “buttons”; @import “base”; .container { @include desktop { @include clearfix(); } } RealNetworks, Inc.2014/7/31 9
  • 10. SASS - install, compile and watch changes 1. install ruby 2. install sass gem I. gem install sass II. sass -v 3. compile scss into css sass billing.scss billing.css 4. watch single files changes sass –watch billing.scss:billing.css 5. watch folders changes sass –watch stylesheets:dist/css RealNetworks, Inc.2014/7/31 10
  • 11. Output Style 2014/7/31 RealNetworks, Inc. 11 There’re four different output styles to set using –style options in command line. :nested, :expanded, :compact and :compressed. :compressed( in production) .try-again,.tech-diff .try-again{font-size:2.4em;margin-bottom:3.5em} :expanded(using in development/debug) .try-again,.tech-diff .try-again{ font-size:2.4em; margin-bottom:3.5em }
  • 12. More Features… 2014/7/31 RealNetworks, Inc. 12 conditional expressions(@if, @for), Interpolation, %placeholders, Functions Learn more 7 Sass features you should be familiar with Bootstrap-sass