SlideShare a Scribd company logo
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

More Related Content

Similar to Modularization css with sass

SASS Preprocessor
SASS PreprocessorSASS Preprocessor
SASS Preprocessor
Webkul Software Pvt. Ltd.
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
James Pearce
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
Mario Noble
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
Katsunori Tanaka
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
Sven Wolfermann
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
Lucien 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: Slides
alienresident
 
@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
Amr Gawish
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
Sayanee Basu
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
Kianosh Pourian
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
drywallbmb
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
Kianosh Pourian
 
PostCss
PostCssPostCss
PostCss
LearningTech
 
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
Sanjoy 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 & SASS
Steve Krueger
 

Similar to 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
 

Recently uploaded

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 

Recently uploaded (20)

Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 

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