SlideShare a Scribd company logo
1 of 44
Download to read offline
JS DAY -VERONA - May 14th 2014
AndreaVerlicchi @verlok www.andreaverlicchi.eu
Agile CSS Development with
/ SASS
About me
• AndreaVerlicchi!
• Front-end architect

(also PHP developer)!
• www.andreaverlicchi.eu

twitter: @verlok
Let's talk about CSS
CSS can become messy
• Many site sections

home, landings, products, etc.!
• Many page sections

header, footer, main, etc.!
• Many devices

desktop, tablet, smartphone, etc.!
• Many screen resolutions!
• Many colors, fonts, helpers, etc.
CSS can become messy
• Not a unique author!
• Not a unique coding style
CSS can become looong
• long CSS file vs split CSS file

we could split the code into more CSS files,

but it would result in less performing websites

(more HTTP requests)!
• long CSS file vs code readability

code is less readable if files are very long, especially
when you first look to someone else's code
CSS can be repetitive
• Sandboxed rules!
article header {...}

article h1 {...}

article p {...}

article footer {...}

article .author {...}!
• Rules that share styles!
button { background-color: #BADA55 }

a { color: #BADA55 }

body { border-bottom: 5px solid #BADA55 }
CSS is not a complete
language
• No variables (yet)!
• No extensibility!
• No math (yet)!
• Just a few functions (rgb, rgba, ...)
What if all this
could CHANGE?
What if we could use...
What if we could use...
Variables?Nesting?
Functions? Math?
Partials?
Variables?Nesting?
Functions? Math?
SASS
Sass is the most mature, stable, and powerful
professional grade CSS extension language in the
world.!
http://sass-lang.com
HOW IT WORKS - DEV
YOU WRITE SASS / SCSS
IT CREATES CSS
IT WATCHES!
FOR CHANGES
HOW IT WORKS - PROD
YOU WRITE SASS / SCSS
COMPILE
IT CREATES CSS
NESTING
!
!
article li {	
margin-right: 1em;	
}	
!
article a {	
color: white;	
background: red;	
display: block;	
}	
!
article a:hover {	
color: red;	
background: white;	
}
article {	
!
li {	
margin-right: 1em;	
}	
!
a {	
color: white;	
background: red;	
display: block;	
!
&:hover {	
color: red;	
background: white;	
}	
}	
}
!
!
button {	
background: #CE4DD6;	
}	
!
a {	
color: #CE4DD6;	
}	
!
header {	
border-bottom: 3px;	
border-color: #CE4DD6;	
}
$mainColor: #CE4DD6;	
!
button {	
background: $mainColor;	
}	
!
a {	
color: $mainColor;	
}	
!
header {	
border-bottom: 3px;	
border-color: $mainColor;	
}
VARIABLES
FUNCTIONS
button {	
color: #CE4DD6;	
}	
!
button:hover {	
color: #D76DDE;	
}
button {	
color: $mainColor;	
}	
!
button:hover {	
color: saturate($mainColor, 10%);	
}
MATH
!
!
#side {	
width: 23.95833%;	
margin: 2.08333%;	
}	
!
#main {	
width: 47.91667%;	
margin: 2.08333%;	
}	
!
#more {	
width: 23.95833%;	
}
$width: 960px;	
!
#side {	
width: percentage(230px / $width);	
margin: percentage(10px / $width);	
}	
!
#main {	
width: percentage(460px / $width);	
margin: percentage(10px / $width);	
}	
!
#more {	
width: percentage(230px / $width);	
}
PARTIALS
// === site.scss ===	
!
@import "normalize";	
@import "fonts";	
@import "mixins"; 	
@import "headerFooter";	
@import "helpers";	
@import "forms";	
…	
…	
…	
@import "whatever";
(very long CSS file)

!html {	
line-height:1;	
}	
!ol,ul {	
list-style:none;	
}	
!table {	
border-collapse:collapse;	
border-spacing:0;	
}	
!caption,th,td {	
text-align:left;	
font-weight:400;	
vertical-align:middle;	
}	
!q,blockquote {	
quotes:none;	
}	
!q:before,q:after,blockquote:before,blockquote:after {	
content:none;	
}	
!a img {	
border:none;	
}	
!body {	
font-family:Tahoma, sans-serif;	
font-size:87.5%;	
-webkit-text-size-adjust:none;	
}	
!h1,h2,h3,h4,h5,h6,#payoff {	
line-height:1.5em;	
}	
!p {	
margin-bottom:6px;	
line-height:1.5em;	
}	
!abbr,acronym {	
border-bottom:1px dotted #690;	
cursor:help;	
}	
!#language,#loginMessage {	
position:absolute;	
}	
!#content {	
position:relative;	
}	
!#accountZone {	
display:none;	
float:right;	
border-radius:10px;	
}	
!#accountZone li {	
display:block;	
float:left;	
}	
!#accountZone a {	
display:block;	
padding:8px 10px;	
}	
!#accountZone form,#accountZone #regeneratePwd {	
float:left;	
}	
!#loginForm form {	
padding:6px 10px 5px;	
}	
!#loginForm button {	
font-size:91.66667%;	
border:0;	
background:#eee;	
height:18px;	
text-align:center;	
width:auto;	
box-shadow:inset 0 -2px 5px rgba(0,0,0,0.3);	
margin:0;	
}	
!#loginForm input {	
width:76px;	
height:18px;	
border:none;	
font-size:100%;	
outline:none;	
box-shadow:inset 0 2px 5px rgba(0,0,0,0.3);	
padding:0 2px;	
}	
!…	
…	
…	
…	
…
SASS 3 does all this
(and lots more)
It allows you to do
powerful operations!
using Mixins
It allows to choose the
output CSS style,
including Compressed
It can remove
comments you don't
want to publish
// this is a shameful hack
However, some
developers still don't like
it...
...hard to debug?
COMPASS
Compass is an open-source CSS Authoring Framework.
Compass uses SASS.!
http://compass-style.org
COMPASS extends SASS
+ it gives you some
interesting features
Click on the file name:line to
view the CSS file inspector

to get the original SASS/SCSS
file name and line
1. IT'S EASY TO DEBUG!
Inspect the element you
want to debug 

to get the CSS rules in
the inspector
2. IT'S LOADED WITH
LOTS OF HELPERS &
PATTERNS
CSS3,Typography, Utilities (Reset,
Clearfix), Sticky Footer, and more
You just add the images, it
generates the sprite + gives you a
helper to use your images
3. IT MAKES CSS SPRITES
3. IT MAKES CSS SPRITES
@import "compass/utilities/sprites";	
!
@import “sponsors/*.png”; // windowsAzure.png, appDynamics.png …	
!
#sponsor_section {	
	 .sponsor1 {	
	 	 @include sponsors-sprite(windowsAzure, true);	
	 }	
!
	 .sponsor2 {	
	 	 @include sponsors-sprite(appDynamics, true);	
	 }	
}
#sponsor_section .sponsor1,	
#sponsor_section .sponsor2,	
#sponsor_section .sponsor3 {	
	 background: url('../img/sponsors-s69e070e3f8.png') no-repeat;	
}	
!
#sponsor_section .sponsor1 {	
	 background-position: 0 0;	
	 height: 171px;	
	 width: 457px;	
}	
!
#sponsor_section .sponsor2 {	
	 background-position: 0 -356px;	
	 height: 95px;	
	 width: 373px;	
}
3. IT MAKES CSS SPRITES
Resume
SASS
• Nesting!
• Variables!
• Functions!
• Math!
• Partials
• Easy debugging!
• Easy spriting!
• Lots of helpers
COMPASS
ORGANIZATION
• Better code organization!
• No code repetition (DRY)!
• Shorter files to manage!
• Much speeder coding
HOW TO INSTALL
• Download Ruby

rubyinstaller.org!
• Command prompt:

gem install compass
• Download Ruby

ruby-lang.com!
• Terminal:

sudo gem install
compass
HOW TO SETUP
• in terminal / command prompt

go to your project folder

cd {your/project/path}!
• create the scaffolding 

compass install compass!
• start watching changes / creating CSS

compass watch
HOW TO START
• SCSS format is CSS compliant!
• You can start writing SCSS as if you were
writing CSS / Rename your CSS files in
SCSS!
• Start using variables and nesting!
• Organize your CSS code in partials!
• Do more complex things using mixins, etc.
SOME ADVICE
• Keep in mind that you’re still writing CSS,
always figure how your CSS will become!
• Avoid unnecessary nesting 

(a maximum of 3 levels is often enough)!
• In continuous integration environments,
always run compass clean before compass
compile (especially if you use branches)
GIVE IT A TRY !
• It takes no more than 30 minutes to be
installed and learned!
• It's used by more and more front-end
developers and companies!
• It would improve your technical skills
twitter: verlok!
www.andreaverlicchi.eu
Q&A
@verlok #jsday

More Related Content

More from Andrea Verlicchi

How and Why ($) to improve web performance.pdf
How and Why ($) to improve web performance.pdfHow and Why ($) to improve web performance.pdf
How and Why ($) to improve web performance.pdfAndrea Verlicchi
 
Come e perché ($) migliorare le prestazioni web.pdf
Come e perché ($) migliorare le prestazioni web.pdfCome e perché ($) migliorare le prestazioni web.pdf
Come e perché ($) migliorare le prestazioni web.pdfAndrea Verlicchi
 
Come e perché ($) migliorare le prestazioni web - Aprile 2023.pptx
Come e perché ($) migliorare le prestazioni web - Aprile 2023.pptxCome e perché ($) migliorare le prestazioni web - Aprile 2023.pptx
Come e perché ($) migliorare le prestazioni web - Aprile 2023.pptxAndrea Verlicchi
 
2022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.02022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.0Andrea Verlicchi
 
Responsive images, an html 5.1 standard
Responsive images, an html 5.1 standardResponsive images, an html 5.1 standard
Responsive images, an html 5.1 standardAndrea Verlicchi
 
Sviluppo CSS agile con SASS e Compass - CSS Day 2015 Faenza
Sviluppo CSS agile con SASS e Compass - CSS Day 2015 FaenzaSviluppo CSS agile con SASS e Compass - CSS Day 2015 Faenza
Sviluppo CSS agile con SASS e Compass - CSS Day 2015 FaenzaAndrea Verlicchi
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryAndrea Verlicchi
 

More from Andrea Verlicchi (7)

How and Why ($) to improve web performance.pdf
How and Why ($) to improve web performance.pdfHow and Why ($) to improve web performance.pdf
How and Why ($) to improve web performance.pdf
 
Come e perché ($) migliorare le prestazioni web.pdf
Come e perché ($) migliorare le prestazioni web.pdfCome e perché ($) migliorare le prestazioni web.pdf
Come e perché ($) migliorare le prestazioni web.pdf
 
Come e perché ($) migliorare le prestazioni web - Aprile 2023.pptx
Come e perché ($) migliorare le prestazioni web - Aprile 2023.pptxCome e perché ($) migliorare le prestazioni web - Aprile 2023.pptx
Come e perché ($) migliorare le prestazioni web - Aprile 2023.pptx
 
2022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.02022.04 - CSS Day IT - Images Optimisation 4.0
2022.04 - CSS Day IT - Images Optimisation 4.0
 
Responsive images, an html 5.1 standard
Responsive images, an html 5.1 standardResponsive images, an html 5.1 standard
Responsive images, an html 5.1 standard
 
Sviluppo CSS agile con SASS e Compass - CSS Day 2015 Faenza
Sviluppo CSS agile con SASS e Compass - CSS Day 2015 FaenzaSviluppo CSS agile con SASS e Compass - CSS Day 2015 Faenza
Sviluppo CSS agile con SASS e Compass - CSS Day 2015 Faenza
 
Css3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQueryCss3 transitions and animations + graceful degradation with jQuery
Css3 transitions and animations + graceful degradation with jQuery
 

Recently uploaded

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
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
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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 Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Recently uploaded (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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 Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

Agile css development with Compass/SASS

  • 1. JS DAY -VERONA - May 14th 2014 AndreaVerlicchi @verlok www.andreaverlicchi.eu Agile CSS Development with / SASS
  • 2. About me • AndreaVerlicchi! • Front-end architect
 (also PHP developer)! • www.andreaverlicchi.eu
 twitter: @verlok
  • 4. CSS can become messy • Many site sections
 home, landings, products, etc.! • Many page sections
 header, footer, main, etc.! • Many devices
 desktop, tablet, smartphone, etc.! • Many screen resolutions! • Many colors, fonts, helpers, etc.
  • 5. CSS can become messy • Not a unique author! • Not a unique coding style
  • 6. CSS can become looong • long CSS file vs split CSS file
 we could split the code into more CSS files,
 but it would result in less performing websites
 (more HTTP requests)! • long CSS file vs code readability
 code is less readable if files are very long, especially when you first look to someone else's code
  • 7. CSS can be repetitive • Sandboxed rules! article header {...}
 article h1 {...}
 article p {...}
 article footer {...}
 article .author {...}! • Rules that share styles! button { background-color: #BADA55 }
 a { color: #BADA55 }
 body { border-bottom: 5px solid #BADA55 }
  • 8. CSS is not a complete language • No variables (yet)! • No extensibility! • No math (yet)! • Just a few functions (rgb, rgba, ...)
  • 9. What if all this could CHANGE?
  • 10. What if we could use...
  • 11. What if we could use... Variables?Nesting? Functions? Math?
  • 13. SASS Sass is the most mature, stable, and powerful professional grade CSS extension language in the world.! http://sass-lang.com
  • 14. HOW IT WORKS - DEV YOU WRITE SASS / SCSS IT CREATES CSS IT WATCHES! FOR CHANGES
  • 15. HOW IT WORKS - PROD YOU WRITE SASS / SCSS COMPILE IT CREATES CSS
  • 16. NESTING ! ! article li { margin-right: 1em; } ! article a { color: white; background: red; display: block; } ! article a:hover { color: red; background: white; } article { ! li { margin-right: 1em; } ! a { color: white; background: red; display: block; ! &:hover { color: red; background: white; } } }
  • 17. ! ! button { background: #CE4DD6; } ! a { color: #CE4DD6; } ! header { border-bottom: 3px; border-color: #CE4DD6; } $mainColor: #CE4DD6; ! button { background: $mainColor; } ! a { color: $mainColor; } ! header { border-bottom: 3px; border-color: $mainColor; } VARIABLES
  • 18. FUNCTIONS button { color: #CE4DD6; } ! button:hover { color: #D76DDE; } button { color: $mainColor; } ! button:hover { color: saturate($mainColor, 10%); }
  • 19. MATH ! ! #side { width: 23.95833%; margin: 2.08333%; } ! #main { width: 47.91667%; margin: 2.08333%; } ! #more { width: 23.95833%; } $width: 960px; ! #side { width: percentage(230px / $width); margin: percentage(10px / $width); } ! #main { width: percentage(460px / $width); margin: percentage(10px / $width); } ! #more { width: percentage(230px / $width); }
  • 20. PARTIALS // === site.scss === ! @import "normalize"; @import "fonts"; @import "mixins"; @import "headerFooter"; @import "helpers"; @import "forms"; … … … @import "whatever"; (very long CSS file)
 !html { line-height:1; } !ol,ul { list-style:none; } !table { border-collapse:collapse; border-spacing:0; } !caption,th,td { text-align:left; font-weight:400; vertical-align:middle; } !q,blockquote { quotes:none; } !q:before,q:after,blockquote:before,blockquote:after { content:none; } !a img { border:none; } !body { font-family:Tahoma, sans-serif; font-size:87.5%; -webkit-text-size-adjust:none; } !h1,h2,h3,h4,h5,h6,#payoff { line-height:1.5em; } !p { margin-bottom:6px; line-height:1.5em; } !abbr,acronym { border-bottom:1px dotted #690; cursor:help; } !#language,#loginMessage { position:absolute; } !#content { position:relative; } !#accountZone { display:none; float:right; border-radius:10px; } !#accountZone li { display:block; float:left; } !#accountZone a { display:block; padding:8px 10px; } !#accountZone form,#accountZone #regeneratePwd { float:left; } !#loginForm form { padding:6px 10px 5px; } !#loginForm button { font-size:91.66667%; border:0; background:#eee; height:18px; text-align:center; width:auto; box-shadow:inset 0 -2px 5px rgba(0,0,0,0.3); margin:0; } !#loginForm input { width:76px; height:18px; border:none; font-size:100%; outline:none; box-shadow:inset 0 2px 5px rgba(0,0,0,0.3); padding:0 2px; } !… … … … …
  • 21. SASS 3 does all this (and lots more)
  • 22. It allows you to do powerful operations! using Mixins
  • 23. It allows to choose the output CSS style, including Compressed
  • 24. It can remove comments you don't want to publish // this is a shameful hack
  • 25. However, some developers still don't like it...
  • 27. COMPASS Compass is an open-source CSS Authoring Framework. Compass uses SASS.! http://compass-style.org
  • 28. COMPASS extends SASS + it gives you some interesting features
  • 29. Click on the file name:line to view the CSS file inspector
 to get the original SASS/SCSS file name and line 1. IT'S EASY TO DEBUG! Inspect the element you want to debug 
 to get the CSS rules in the inspector
  • 30. 2. IT'S LOADED WITH LOTS OF HELPERS & PATTERNS CSS3,Typography, Utilities (Reset, Clearfix), Sticky Footer, and more
  • 31. You just add the images, it generates the sprite + gives you a helper to use your images 3. IT MAKES CSS SPRITES
  • 32. 3. IT MAKES CSS SPRITES @import "compass/utilities/sprites"; ! @import “sponsors/*.png”; // windowsAzure.png, appDynamics.png … ! #sponsor_section { .sponsor1 { @include sponsors-sprite(windowsAzure, true); } ! .sponsor2 { @include sponsors-sprite(appDynamics, true); } }
  • 33. #sponsor_section .sponsor1, #sponsor_section .sponsor2, #sponsor_section .sponsor3 { background: url('../img/sponsors-s69e070e3f8.png') no-repeat; } ! #sponsor_section .sponsor1 { background-position: 0 0; height: 171px; width: 457px; } ! #sponsor_section .sponsor2 { background-position: 0 -356px; height: 95px; width: 373px; } 3. IT MAKES CSS SPRITES
  • 35. SASS • Nesting! • Variables! • Functions! • Math! • Partials
  • 36. • Easy debugging! • Easy spriting! • Lots of helpers COMPASS
  • 37. ORGANIZATION • Better code organization! • No code repetition (DRY)! • Shorter files to manage! • Much speeder coding
  • 38. HOW TO INSTALL • Download Ruby
 rubyinstaller.org! • Command prompt:
 gem install compass • Download Ruby
 ruby-lang.com! • Terminal:
 sudo gem install compass
  • 39. HOW TO SETUP • in terminal / command prompt
 go to your project folder
 cd {your/project/path}! • create the scaffolding 
 compass install compass! • start watching changes / creating CSS
 compass watch
  • 40. HOW TO START • SCSS format is CSS compliant! • You can start writing SCSS as if you were writing CSS / Rename your CSS files in SCSS! • Start using variables and nesting! • Organize your CSS code in partials! • Do more complex things using mixins, etc.
  • 41. SOME ADVICE • Keep in mind that you’re still writing CSS, always figure how your CSS will become! • Avoid unnecessary nesting 
 (a maximum of 3 levels is often enough)! • In continuous integration environments, always run compass clean before compass compile (especially if you use branches)
  • 42. GIVE IT A TRY ! • It takes no more than 30 minutes to be installed and learned! • It's used by more and more front-end developers and companies! • It would improve your technical skills

Editor's Notes

  1. \n
  2. for Cavalli, D&G, Armani, StellaMC\n\n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. WITH SASS, WE CAN\n
  30. WITH SASS, WE CAN\n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n