SlideShare a Scribd company logo
1 of 47
Welcome to the technical session 
on 
Syntactically Awesome Stylesheets
How to write 
Maintainable CSS 
by using 
Presented by - 
Tahmina Khatoon 
Software Engineer
Objectives 
• Introduction to Sass 
– Why adding Sass in our workflow 
– Advantages of Sass 
• The power of Sass 
– How to convert our CSS into Sass 
• Compass 
– What is Compass 
– How to use sass with compass 
• Example 
– Example of Sass Project 
9/1/2014 3
Measuring simplicity of CSS 
• Slight variations of colors, fonts, numbers, & 
other properties arise 
• Effective curbing of repetition can decline 
• Stylesheet size may become unmanageable 
9/1/2014 4
CSS Preposassor 
• CSS preprocessors take code written in the 
preprocessed language and then convert that 
code into CSS. 
• 3 of the more popular CSS preprocessors are 
Sass, LESS and Stylus 
9/1/2014 Technical session on Sass 5
Sass 
• Syntactically Awesome Stylesheets 
• Looks like CSS, but adds features to combat shortcomings 
• Preprocessor, like CoffeeScript & Haml 
9/1/2014 Technical session on Sass 6
History of Sass 
• Initially designed by Hampton Catlin, 
also the creator of Haml and developed 
by Nathan Weizenbaum 
• After its initial versions, Weizenbaum 
and Chris Eppstein have continued to 
extend Sass with SassScript 
Hampton Catlin 
9/1/2014 Technical session on Sass 7
File Extension 
.sass 
• Older original file type 
• Allows to write css without 
any curly-brackets or semi-colons 
• Selectors and properties are 
distinguished by indentation 
.scss 
• More similar to regular css 
• it adds in all the sass 
helpers like indentation, 
variables and more 
• Any regular .css file is a valid 
.scss file 
9/1/2014 Technical session on Sass 8
.sass & .scss examples 
style.scss style.sass 
$main: #444; 
.btn 
color: $main 
display: block 
.btn-a 
color: lighten($main, 30%) 
&:hover 
color: lighten($main, 40%) 
$main: #444; 
.btn { 
color: $main; 
display: block; 
} 
.btn-a { 
color: lighten($main, 30%); 
&:hover { 
color: lighten($main, 40%); 
} 
} 
9/1/2014 Technical session on Sass 9
.scss & .css examples 
style.scss style.css 
.btn { 
color: #444444; 
display: block; 
} 
.btn-a { 
color: #919191; 
} 
.btn-a:hover { 
color: #aaaaaa; 
} 
$main: #444; 
.btn { 
color: $main; 
display: block; 
} 
.btn-a { 
color: lighten($main, 30%); 
&:hover { 
color: lighten($main, 40%); 
} 
} 
9/1/2014 Technical session on Sass 10
Sass features 
• Variable 
• Importing 
• Nesting Selectors 
• Mixin 
• Extend 
• Directive 
• Math + Color 
• and more ... 
9/1/2014 Technical session on Sass 11
Ways to start using Sass ... 
• Command lines 
• Applications 
9/1/2014 Technical session on Sass 12
Ways to start using Sass ... 
Pre-installation 
• Linux 
– Need to install Ruby 
• Windows 
– Need to install Ruby 
• Mac 
– Ruby is pre-installed 
Install Sass 
Open your Terminal or Command Prompt. 
Command lines 
gem install sass 
Check sass version 
sass -v 
9/1/2014 Technical session on Sass 13
Ways to start using Sass ... 
• Applications 
– CodeKit (Paid) 
– Compass.app (Paid, Open Source) 
– Hammer (Paid) 
– Koala (Open Source) 
– LiveReload (Paid, Open Source) 
– Mixture (Paid) 
– Prepros (Paid, Open Source) 
– Scout (Open Source) 
9/1/2014 Technical session on Sass 14
Compile & Watch 
Compile any sass file 
sass input.sass output.css 
Watch any sass file 
sass –-watch input.sass:output.css 
Watch any folder 
sass –-watch sass:stylesheet 
For help 
sass -–help 
9/1/2014 Technical session on Sass 15
Commenting 
application.scss 
// This comment will not be output 
// to the compiled css file 
/* This comment will display */ 
application.css 
/* This comment will display */ 
9/1/2014 Technical session on Sass 16
Importing 
• @import from a CSS file should almost 
never be used, as it can prevent 
stylesheets from being downloaded 
concurrently. 
• @import with .scss or .sass happens 
during compile rather than client-side 
• File extension is not required. 
application.css 
/** 
* Import style 
* ‘form.css’ has found, 
* when application.css 
* has requested by browser 
*/ 
@import ‘form.css’; 
9/1/2014 Technical session on Sass 17
Importing ... 
application.scss 
/** 
* Import style ‘form’ has found, 
* when application.css is processed by compiler 
*/ 
@import ‘form’; 
application.scss 
form.scss 
application.css 
9/1/2014 Technical session on Sass 18
Importing ... 
application.scss 
/** 
* Import style ‘form’ has found, 
* when application.css is processed by compiler 
*/ 
@import ‘form’; 
application.scss 
form.scss 
application.css 
form.css 
9/1/2014 Technical session on Sass 19
Partials 
application.scss 
/** 
* Import style ‘form’ has found, 
* when application.css is processed by compiler 
*/ 
@import ‘form’; 
application.scss 
_form.scss 
application.css 
9/1/2014 Technical session on Sass 20
Nesting 
• CSS does support logical nesting, but the code blocks 
themselves are not nested. 
• Sass allows the nested code to be inserted within each other 
nesting.scss nesting.scss 
.content{ 
border: 1px solid #ccc; 
padding: 20px; 
} 
.content h2{ 
color: #FF0000; 
} 
.content p{ 
font-size: 12px; 
} 
.content{ 
border: 1px solid #ccc; 
padding: 20px; 
h2{ 
color: #FF0000; 
} 
p{ 
font-size: 12px; 
} 
} 
9/1/2014 Technical session on Sass 21
Nesting features 
• Property nesting 
• Parent selector 
• Before reference selector 
9/1/2014 Technical session on Sass 22
Variables 
• Native CSS variable support is still in its infancy, 
but Sass affords us a way to set reusable values 
• Variable names begin with $, like $base 
variables.scss 
$base: #777777; 
.sidebar { 
border: 1px solid $base; 
p { 
color: $base; 
} 
} 
variables.css 
.sidebar { 
border: 1px solid #777777; 
} 
.sidebar p { 
color: #777777; 
} 
9/1/2014 Technical session on Sass 23
Variables ... 
• Default Flag 
– Variable definitions can optionally take the 
!default flag 
default.scss 
$blue: blue; 
$blue: red; 
.content-navigation { 
border-color: $blue; 
color: 
darken($blue, 20%); 
} 
/** 
* Result red color 
*/ 
default.css 
$blue: blue; 
$blue: red !default; 
.content-navigation { 
border-color: $blue; 
color: 
darken($blue, 20%); 
} 
/** 
* Result bluecolor 
*/ 
9/1/2014 Technical session on Sass 24
Variables ... 
• Types of variables 
– Booleans 
– Numbers - can be set with or without units: 
– Colors 
– Strings - can be set with or without quotes: 
– Lists 
– Null 
9/1/2014 Technical session on Sass 25
Variables ... 
• Scope of variables 
– Variables set inside a declaration (within { }) aren't usable outside that 
block 
– Setting new values to variables set outside a declaration changes 
future instances 
scope.scss 
$color-base: #777777; 
.sidebar { 
$color-base: #222222; 
background: $color-base; 
} 
p { 
color: $color-base; 
} 
scope.css 
.sidebar { 
background: #222222; 
} 
p { 
color: #222222; 
} 
9/1/2014 Technical session on Sass 26
Variables ... 
• Interpolation 
– Use the Ruby-esque #{$variable} to shim variables into selectors, 
property names, and strings 
interpolation.scss 
/* Interpolation */ 
$side: top; 
sup { 
position: relative; 
#{$side}: -0.5em; 
} 
.callout-#{$side} { 
background: #777; 
} 
interpolation.css 
/* Interpolation */ 
sup { 
position: relative; 
top: -0.5em; 
} 
.callout-top { 
background: #777; 
} 
9/1/2014 Technical session on Sass 27
Mixins 
• CSS does not support mixins. Any repeated code must be 
repeated in each location. 
• A mixin is a section of code that contains any valid Sass code. 
• Whenever a mixin is called, the result of translating the mixin 
is inserted at the calling location. 
• Mixins allow for efficient and clean code repetitions, as well 
as easy alteration of code 
Before mixin (at CSS) After mixin (at Sass) 
9/1/2014 Technical session on Sass 28
Mixins 
• Block of reusable code that takes optional 
arguments 
application.scss 
@mixin button { 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
} 
.btn-a { 
@include button; 
background: #777; 
} 
.btn-b { 
@include button; 
background: #ff0; 
} 
application.css 
.btn-a { 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
background: #777; 
} 
.btn-b { 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
background: #ff0; 
} 
9/1/2014 Technical session on Sass 29
Mixin with arguments 
application.scss 
@mixin border-radius($radius: 10px) { 
-moz-border-radius: $radius; 
-webkit-border-radius: $radius; 
border-radius: $radius; 
} 
.container { 
@include border-radius(5px); 
} 
.button { 
@include border-radius(3px); 
} 
application.css 
.container { 
-moz-border-radius: 5px; 
-webkit-border-radius: 5px; 
border-radius: 5px; 
} 
.button { 
-moz-border-radius: 3px; 
-webkit-border-radius: 3px; 
border-radius: 3px; 
} 
9/1/2014 Technical session on Sass 30
Extends 
• Extends the properties of one decoration to 
another decoration. 
extend.css 
.btn-a { 
background: #777; 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
} 
.btn-b { 
background: #ff0; 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
} 
extend.css 
.btn-a, 
.btn-b { 
background: #777; 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
} 
.btn-b { 
background: #ff0; 
} 
9/1/2014 Technical session on Sass 31
Extends 
• Sass will track and automatically combine 
selectors for us: 
extend.scss 
.btn-a { 
background: #777; 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
} 
.btn-b { 
@extend .btn-a; 
background: #ff0; 
} 
extend.css 
.btn-a, 
.btn-b { 
background: #777; 
border: 1px solid #ccc; 
font-size: 1em; 
text-transform: uppercase; 
} 
.btn-b { 
background: #ff0; 
} 
9/1/2014 Technical session on Sass 32
Nesting + Extends 
extend.scss 
.content { 
border: 1px solid #ccc; 
padding: 20px; 
h2 { 
font-size: 3em; 
margin: 20px 0; 
} 
} 
.callout { 
@extend .content; 
background: #ddd; 
} 
extend.css 
.content, .callout { 
border: 1px solid #ccc; 
padding: 20px; 
} 
.content h2, .callout h2 { 
font-size: 3em; 
margin: 20px 0; 
} 
.callout { 
background: #ddd; 
} 
9/1/2014 Technical session on Sass 33
Placeholder 
• Placeholder selectors are denoted with a % 
• Can be extended, but never become a selector 
of their own 
9/1/2014 Technical session on Sass 34
Placeholder 
extend.scss 
/* Place holder example */ 
%content { 
border: 1px solid #ccc; 
padding: 20px; 
} 
.content { 
@extend %content; 
h2 { 
font-size: 3em; 
margin: 20px 0; 
} 
} 
.callout { 
@extend %content; 
background: #ddd; 
} 
extend.css 
/* Place holder example */ 
.content, .callout { 
border: 1px solid #ccc; 
padding: 20px; 
} 
.content h2 { 
font-size: 3em; 
margin: 20px 0; 
} 
.callout { 
background: #ddd; 
} 
9/1/2014 Technical session on Sass 35
Functions 
• SassScript defines some useful functions that are 
called using the normal CSS function syntax 
function.scss 
$base-color: #000000; 
body{ 
background: lighten($base-color, 
20%); 
} 
function.css 
body { 
background: #333333; 
} 
9/1/2014 Technical session on Sass 36
Functions ... 
• Several predefined functions 
– RGB Functions 
– Opacity Functions 
– String Functions 
– Number Functions 
– List Functions 
– Map Functions 
– Introspection Functions 
See http://sass-lang.com/documentation/Sass/Script/Functions.html 
for a full listing of Sass functions and their argument names 
9/1/2014 Technical session on Sass 37
Functions ... 
• Custom function 
function.scss 
/* Without argument */ 
@function fluidize() { 
@return 35%; 
} 
.sidebar_a { 
width: fluidize(); 
} 
/* With argument */ 
@function fluidize_arguments($target, 
$context){ 
@return ($target / $context) * 
100%; 
} 
.sidebar_b { 
width: fluidize_arguments(300px, 
1000px); 
} 
function.css 
/* Without argument */ 
.sidebar_a { 
width: 35%; 
} 
/* With argument */ 
.sidebar_b { 
width: 30%; 
} 
9/1/2014 Technical session on Sass 38
Compass 
• Open-source CSS Authoring Framework 
• Adds reusable patterns, utilities, and modules 
like vertical rhythm and spriting 
• Created by Chris Eppstein as charityware 
• Other core team members: Scott Davis, Eric 
Meyer, Brandon Mathis, and Anthony Short 
9/1/2014 Technical session on Sass 40
Advantages of using compass 
• Experience cleaner markup without 
presentational classes. 
• It’s chock full of the web’s best reusable 
patterns. 
• Compass mixins make CSS3 easy. 
• Create beautiful typographic rhythms. 
9/1/2014 Technical session on Sass 41
Compass installation 
Install compass 
gem install compass 
For help 
compass -–help 
9/1/2014 Technical session on Sass 42
Project setup with compass 
Initialize compass project 
compass init 
Watch any folder 
# Set this to the root of your project when deployed: 
http_path = "/" 
css_dir = "css" 
sass_dir = "sass" 
images_dir = "images" 
javascripts_dir = "javascripts“ 
# You can select your preferred output style here (can be overridden via the command 
line): 
# output_style = :expanded or :nested or :compact or :compressed 
Watch any folder 
compass watch 
9/1/2014 Technical session on Sass 43
Compass Utilities 
• Links – Tools for styling anchor links. 
• Lists – Tools for styling lists. 
• Text – Style helpers for your text. 
• Color – Utilities for working with colors. 
• General – Generally useful utilities that don't fit elsewhere. 
• Sprites – Sprite mixins. 
• Tables – Style helpers for your tables. 
9/1/2014 Technical session on Sass 44
Sprite example 
@import "compass/utilities/sprites"; 
@import "icons/*.png"; 
body{ 
background: black; 
} 
$hight: icons-sprite-height(student); 
$width: icons-sprite-width(student); 
.icons { 
display: block; 
height: $hight; 
width: $width; 
} 
@include all-icons-sprites; 
9/1/2014 Technical session on Sass 45
Any Questions 
on how to write maintainable css by using sass?
Thank you 
for your patience and participating in this session.

More Related Content

What's hot

CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout Rachel Andrew
 
Mediaqueries
MediaqueriesMediaqueries
MediaqueriesBrillio
 
Media queries A to Z
Media queries A to ZMedia queries A to Z
Media queries A to ZShameem Reza
 
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
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers10Clouds
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksAmit Tyagi
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media QueriesRuss Weakley
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCEAnuradha
 
CSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignZoe Gillenwater
 
Welcome to Blazor
Welcome to BlazorWelcome to Blazor
Welcome to Blazordark_wisdom
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreRuss Weakley
 
Tailwind CSS.11.pptx
Tailwind CSS.11.pptxTailwind CSS.11.pptx
Tailwind CSS.11.pptxHarish Verma
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designersSingsys Pte Ltd
 
9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classesIn a Rocket
 

What's hot (20)

Sass presentation
Sass presentationSass presentation
Sass presentation
 
Sass
SassSass
Sass
 
Less vs sass
Less vs sassLess vs sass
Less vs sass
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
 
Mediaqueries
MediaqueriesMediaqueries
Mediaqueries
 
Media queries A to Z
Media queries A to ZMedia queries A to Z
Media queries A to Z
 
Less presentation
Less presentationLess presentation
Less presentation
 
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)
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
CSS3 Media Queries
CSS3 Media QueriesCSS3 Media Queries
CSS3 Media Queries
 
CSS INHERITANCE
CSS INHERITANCECSS INHERITANCE
CSS INHERITANCE
 
CSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive DesignCSS3, Media Queries, and Responsive Design
CSS3, Media Queries, and Responsive Design
 
Welcome to Blazor
Welcome to BlazorWelcome to Blazor
Welcome to Blazor
 
Css
CssCss
Css
 
CSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and moreCSS - OOCSS, SMACSS and more
CSS - OOCSS, SMACSS and more
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Tailwind CSS.11.pptx
Tailwind CSS.11.pptxTailwind CSS.11.pptx
Tailwind CSS.11.pptx
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes9- Learn CSS Fundamentals / Pseudo-classes
9- Learn CSS Fundamentals / Pseudo-classes
 

Viewers also liked

Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshopShaho Toofani
 
Dvcs With Mercurial (No Notes)
Dvcs With Mercurial (No Notes)Dvcs With Mercurial (No Notes)
Dvcs With Mercurial (No Notes)Ted Naleid
 
CSS3 Flex Layout
CSS3 Flex LayoutCSS3 Flex Layout
CSS3 Flex LayoutNeha Sharma
 
Sp rp administracja
Sp rp   administracjaSp rp   administracja
Sp rp administracjap_andora
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayChamnap Chhorn
 
CSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle ApproachCSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle ApproachJulie Kuehl
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized军 沈
 
Smart CSS theming with Sass and Compass
Smart CSS theming with Sass and CompassSmart CSS theming with Sass and Compass
Smart CSS theming with Sass and CompassMihaela
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptForziatech
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript ConceptsNaresh Kumar
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptzand3rs
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternNarendra Sisodiya
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quickBilly Shih
 
The ultimate guide to prototyping
The ultimate guide to prototypingThe ultimate guide to prototyping
The ultimate guide to prototypingMarcelo Graciolli
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptSunny Sharma
 

Viewers also liked (20)

Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshop
 
Dvcs With Mercurial (No Notes)
Dvcs With Mercurial (No Notes)Dvcs With Mercurial (No Notes)
Dvcs With Mercurial (No Notes)
 
CSS3 Flex Layout
CSS3 Flex LayoutCSS3 Flex Layout
CSS3 Flex Layout
 
Sp rp administracja
Sp rp   administracjaSp rp   administracja
Sp rp administracja
 
JavaScript in Object-Oriented Way
JavaScript in Object-Oriented WayJavaScript in Object-Oriented Way
JavaScript in Object-Oriented Way
 
CSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle ApproachCSS Sanity with Sass: The Inverted Triangle Approach
CSS Sanity with Sass: The Inverted Triangle Approach
 
Prototype
PrototypePrototype
Prototype
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
Javascript Prototype Visualized
Javascript Prototype VisualizedJavascript Prototype Visualized
Javascript Prototype Visualized
 
Smart CSS theming with Sass and Compass
Smart CSS theming with Sass and CompassSmart CSS theming with Sass and Compass
Smart CSS theming with Sass and Compass
 
Object Oriented Programming In JavaScript
Object Oriented Programming In JavaScriptObject Oriented Programming In JavaScript
Object Oriented Programming In JavaScript
 
JavaScript OOPs
JavaScript OOPsJavaScript OOPs
JavaScript OOPs
 
Advanced JavaScript Concepts
Advanced JavaScript ConceptsAdvanced JavaScript Concepts
Advanced JavaScript Concepts
 
Object Oriented Programming in JavaScript
Object Oriented Programming in JavaScriptObject Oriented Programming in JavaScript
Object Oriented Programming in JavaScript
 
JavaScript Prototype and Module Pattern
JavaScript Prototype and Module PatternJavaScript Prototype and Module Pattern
JavaScript Prototype and Module Pattern
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quick
 
Sas demo
Sas demoSas demo
Sas demo
 
The ultimate guide to prototyping
The ultimate guide to prototypingThe ultimate guide to prototyping
The ultimate guide to prototyping
 
Prototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScriptPrototype & Inheritance in JavaScript
Prototype & Inheritance in JavaScript
 

Similar to Syntactically awesome stylesheets (Sass)

SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassClaudina Sarahe
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Startededgincvg
 
Introducing grunt, npm and sass
Introducing grunt, npm and sassIntroducing grunt, npm and sass
Introducing grunt, npm and sasspriyanka1452
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFxStefan Bauer
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compassChris Lee
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersSuzette Franck
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS ImplementationAmey Parab
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Anam Hossain
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageKatsunori Tanaka
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPressJames Steinbach
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 

Similar to Syntactically awesome stylesheets (Sass) (20)

SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
CSS3
CSS3CSS3
CSS3
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
Introducing grunt, npm and sass
Introducing grunt, npm and sassIntroducing grunt, npm and sass
Introducing grunt, npm and sass
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compass
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress Developers
 
SASS Preprocessor
SASS PreprocessorSASS Preprocessor
SASS Preprocessor
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
PostCss
PostCssPostCss
PostCss
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 

More from Tahmina Khatoon

Building chatbot with amazon lex
Building chatbot with amazon lexBuilding chatbot with amazon lex
Building chatbot with amazon lexTahmina Khatoon
 
How to predict turnover of sales team
How to predict turnover of sales teamHow to predict turnover of sales team
How to predict turnover of sales teamTahmina Khatoon
 
Functional testing with behat
Functional testing with behatFunctional testing with behat
Functional testing with behatTahmina Khatoon
 
Parcel management system - Proposal
Parcel management system - ProposalParcel management system - Proposal
Parcel management system - ProposalTahmina Khatoon
 
Parcel management system - presentation
Parcel management system - presentationParcel management system - presentation
Parcel management system - presentationTahmina Khatoon
 

More from Tahmina Khatoon (7)

Building chatbot with amazon lex
Building chatbot with amazon lexBuilding chatbot with amazon lex
Building chatbot with amazon lex
 
Fundamental of Scrum
Fundamental of ScrumFundamental of Scrum
Fundamental of Scrum
 
How to predict turnover of sales team
How to predict turnover of sales teamHow to predict turnover of sales team
How to predict turnover of sales team
 
Functional testing with behat
Functional testing with behatFunctional testing with behat
Functional testing with behat
 
Meet with Meteor
Meet with MeteorMeet with Meteor
Meet with Meteor
 
Parcel management system - Proposal
Parcel management system - ProposalParcel management system - Proposal
Parcel management system - Proposal
 
Parcel management system - presentation
Parcel management system - presentationParcel management system - presentation
Parcel management system - presentation
 

Recently uploaded

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 

Recently uploaded (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Syntactically awesome stylesheets (Sass)

  • 1. Welcome to the technical session on Syntactically Awesome Stylesheets
  • 2. How to write Maintainable CSS by using Presented by - Tahmina Khatoon Software Engineer
  • 3. Objectives • Introduction to Sass – Why adding Sass in our workflow – Advantages of Sass • The power of Sass – How to convert our CSS into Sass • Compass – What is Compass – How to use sass with compass • Example – Example of Sass Project 9/1/2014 3
  • 4. Measuring simplicity of CSS • Slight variations of colors, fonts, numbers, & other properties arise • Effective curbing of repetition can decline • Stylesheet size may become unmanageable 9/1/2014 4
  • 5. CSS Preposassor • CSS preprocessors take code written in the preprocessed language and then convert that code into CSS. • 3 of the more popular CSS preprocessors are Sass, LESS and Stylus 9/1/2014 Technical session on Sass 5
  • 6. Sass • Syntactically Awesome Stylesheets • Looks like CSS, but adds features to combat shortcomings • Preprocessor, like CoffeeScript & Haml 9/1/2014 Technical session on Sass 6
  • 7. History of Sass • Initially designed by Hampton Catlin, also the creator of Haml and developed by Nathan Weizenbaum • After its initial versions, Weizenbaum and Chris Eppstein have continued to extend Sass with SassScript Hampton Catlin 9/1/2014 Technical session on Sass 7
  • 8. File Extension .sass • Older original file type • Allows to write css without any curly-brackets or semi-colons • Selectors and properties are distinguished by indentation .scss • More similar to regular css • it adds in all the sass helpers like indentation, variables and more • Any regular .css file is a valid .scss file 9/1/2014 Technical session on Sass 8
  • 9. .sass & .scss examples style.scss style.sass $main: #444; .btn color: $main display: block .btn-a color: lighten($main, 30%) &:hover color: lighten($main, 40%) $main: #444; .btn { color: $main; display: block; } .btn-a { color: lighten($main, 30%); &:hover { color: lighten($main, 40%); } } 9/1/2014 Technical session on Sass 9
  • 10. .scss & .css examples style.scss style.css .btn { color: #444444; display: block; } .btn-a { color: #919191; } .btn-a:hover { color: #aaaaaa; } $main: #444; .btn { color: $main; display: block; } .btn-a { color: lighten($main, 30%); &:hover { color: lighten($main, 40%); } } 9/1/2014 Technical session on Sass 10
  • 11. Sass features • Variable • Importing • Nesting Selectors • Mixin • Extend • Directive • Math + Color • and more ... 9/1/2014 Technical session on Sass 11
  • 12. Ways to start using Sass ... • Command lines • Applications 9/1/2014 Technical session on Sass 12
  • 13. Ways to start using Sass ... Pre-installation • Linux – Need to install Ruby • Windows – Need to install Ruby • Mac – Ruby is pre-installed Install Sass Open your Terminal or Command Prompt. Command lines gem install sass Check sass version sass -v 9/1/2014 Technical session on Sass 13
  • 14. Ways to start using Sass ... • Applications – CodeKit (Paid) – Compass.app (Paid, Open Source) – Hammer (Paid) – Koala (Open Source) – LiveReload (Paid, Open Source) – Mixture (Paid) – Prepros (Paid, Open Source) – Scout (Open Source) 9/1/2014 Technical session on Sass 14
  • 15. Compile & Watch Compile any sass file sass input.sass output.css Watch any sass file sass –-watch input.sass:output.css Watch any folder sass –-watch sass:stylesheet For help sass -–help 9/1/2014 Technical session on Sass 15
  • 16. Commenting application.scss // This comment will not be output // to the compiled css file /* This comment will display */ application.css /* This comment will display */ 9/1/2014 Technical session on Sass 16
  • 17. Importing • @import from a CSS file should almost never be used, as it can prevent stylesheets from being downloaded concurrently. • @import with .scss or .sass happens during compile rather than client-side • File extension is not required. application.css /** * Import style * ‘form.css’ has found, * when application.css * has requested by browser */ @import ‘form.css’; 9/1/2014 Technical session on Sass 17
  • 18. Importing ... application.scss /** * Import style ‘form’ has found, * when application.css is processed by compiler */ @import ‘form’; application.scss form.scss application.css 9/1/2014 Technical session on Sass 18
  • 19. Importing ... application.scss /** * Import style ‘form’ has found, * when application.css is processed by compiler */ @import ‘form’; application.scss form.scss application.css form.css 9/1/2014 Technical session on Sass 19
  • 20. Partials application.scss /** * Import style ‘form’ has found, * when application.css is processed by compiler */ @import ‘form’; application.scss _form.scss application.css 9/1/2014 Technical session on Sass 20
  • 21. Nesting • CSS does support logical nesting, but the code blocks themselves are not nested. • Sass allows the nested code to be inserted within each other nesting.scss nesting.scss .content{ border: 1px solid #ccc; padding: 20px; } .content h2{ color: #FF0000; } .content p{ font-size: 12px; } .content{ border: 1px solid #ccc; padding: 20px; h2{ color: #FF0000; } p{ font-size: 12px; } } 9/1/2014 Technical session on Sass 21
  • 22. Nesting features • Property nesting • Parent selector • Before reference selector 9/1/2014 Technical session on Sass 22
  • 23. Variables • Native CSS variable support is still in its infancy, but Sass affords us a way to set reusable values • Variable names begin with $, like $base variables.scss $base: #777777; .sidebar { border: 1px solid $base; p { color: $base; } } variables.css .sidebar { border: 1px solid #777777; } .sidebar p { color: #777777; } 9/1/2014 Technical session on Sass 23
  • 24. Variables ... • Default Flag – Variable definitions can optionally take the !default flag default.scss $blue: blue; $blue: red; .content-navigation { border-color: $blue; color: darken($blue, 20%); } /** * Result red color */ default.css $blue: blue; $blue: red !default; .content-navigation { border-color: $blue; color: darken($blue, 20%); } /** * Result bluecolor */ 9/1/2014 Technical session on Sass 24
  • 25. Variables ... • Types of variables – Booleans – Numbers - can be set with or without units: – Colors – Strings - can be set with or without quotes: – Lists – Null 9/1/2014 Technical session on Sass 25
  • 26. Variables ... • Scope of variables – Variables set inside a declaration (within { }) aren't usable outside that block – Setting new values to variables set outside a declaration changes future instances scope.scss $color-base: #777777; .sidebar { $color-base: #222222; background: $color-base; } p { color: $color-base; } scope.css .sidebar { background: #222222; } p { color: #222222; } 9/1/2014 Technical session on Sass 26
  • 27. Variables ... • Interpolation – Use the Ruby-esque #{$variable} to shim variables into selectors, property names, and strings interpolation.scss /* Interpolation */ $side: top; sup { position: relative; #{$side}: -0.5em; } .callout-#{$side} { background: #777; } interpolation.css /* Interpolation */ sup { position: relative; top: -0.5em; } .callout-top { background: #777; } 9/1/2014 Technical session on Sass 27
  • 28. Mixins • CSS does not support mixins. Any repeated code must be repeated in each location. • A mixin is a section of code that contains any valid Sass code. • Whenever a mixin is called, the result of translating the mixin is inserted at the calling location. • Mixins allow for efficient and clean code repetitions, as well as easy alteration of code Before mixin (at CSS) After mixin (at Sass) 9/1/2014 Technical session on Sass 28
  • 29. Mixins • Block of reusable code that takes optional arguments application.scss @mixin button { border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; } .btn-a { @include button; background: #777; } .btn-b { @include button; background: #ff0; } application.css .btn-a { border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; background: #777; } .btn-b { border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; background: #ff0; } 9/1/2014 Technical session on Sass 29
  • 30. Mixin with arguments application.scss @mixin border-radius($radius: 10px) { -moz-border-radius: $radius; -webkit-border-radius: $radius; border-radius: $radius; } .container { @include border-radius(5px); } .button { @include border-radius(3px); } application.css .container { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } .button { -moz-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px; } 9/1/2014 Technical session on Sass 30
  • 31. Extends • Extends the properties of one decoration to another decoration. extend.css .btn-a { background: #777; border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; } .btn-b { background: #ff0; border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; } extend.css .btn-a, .btn-b { background: #777; border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; } .btn-b { background: #ff0; } 9/1/2014 Technical session on Sass 31
  • 32. Extends • Sass will track and automatically combine selectors for us: extend.scss .btn-a { background: #777; border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; } .btn-b { @extend .btn-a; background: #ff0; } extend.css .btn-a, .btn-b { background: #777; border: 1px solid #ccc; font-size: 1em; text-transform: uppercase; } .btn-b { background: #ff0; } 9/1/2014 Technical session on Sass 32
  • 33. Nesting + Extends extend.scss .content { border: 1px solid #ccc; padding: 20px; h2 { font-size: 3em; margin: 20px 0; } } .callout { @extend .content; background: #ddd; } extend.css .content, .callout { border: 1px solid #ccc; padding: 20px; } .content h2, .callout h2 { font-size: 3em; margin: 20px 0; } .callout { background: #ddd; } 9/1/2014 Technical session on Sass 33
  • 34. Placeholder • Placeholder selectors are denoted with a % • Can be extended, but never become a selector of their own 9/1/2014 Technical session on Sass 34
  • 35. Placeholder extend.scss /* Place holder example */ %content { border: 1px solid #ccc; padding: 20px; } .content { @extend %content; h2 { font-size: 3em; margin: 20px 0; } } .callout { @extend %content; background: #ddd; } extend.css /* Place holder example */ .content, .callout { border: 1px solid #ccc; padding: 20px; } .content h2 { font-size: 3em; margin: 20px 0; } .callout { background: #ddd; } 9/1/2014 Technical session on Sass 35
  • 36. Functions • SassScript defines some useful functions that are called using the normal CSS function syntax function.scss $base-color: #000000; body{ background: lighten($base-color, 20%); } function.css body { background: #333333; } 9/1/2014 Technical session on Sass 36
  • 37. Functions ... • Several predefined functions – RGB Functions – Opacity Functions – String Functions – Number Functions – List Functions – Map Functions – Introspection Functions See http://sass-lang.com/documentation/Sass/Script/Functions.html for a full listing of Sass functions and their argument names 9/1/2014 Technical session on Sass 37
  • 38. Functions ... • Custom function function.scss /* Without argument */ @function fluidize() { @return 35%; } .sidebar_a { width: fluidize(); } /* With argument */ @function fluidize_arguments($target, $context){ @return ($target / $context) * 100%; } .sidebar_b { width: fluidize_arguments(300px, 1000px); } function.css /* Without argument */ .sidebar_a { width: 35%; } /* With argument */ .sidebar_b { width: 30%; } 9/1/2014 Technical session on Sass 38
  • 39.
  • 40. Compass • Open-source CSS Authoring Framework • Adds reusable patterns, utilities, and modules like vertical rhythm and spriting • Created by Chris Eppstein as charityware • Other core team members: Scott Davis, Eric Meyer, Brandon Mathis, and Anthony Short 9/1/2014 Technical session on Sass 40
  • 41. Advantages of using compass • Experience cleaner markup without presentational classes. • It’s chock full of the web’s best reusable patterns. • Compass mixins make CSS3 easy. • Create beautiful typographic rhythms. 9/1/2014 Technical session on Sass 41
  • 42. Compass installation Install compass gem install compass For help compass -–help 9/1/2014 Technical session on Sass 42
  • 43. Project setup with compass Initialize compass project compass init Watch any folder # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "images" javascripts_dir = "javascripts“ # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed Watch any folder compass watch 9/1/2014 Technical session on Sass 43
  • 44. Compass Utilities • Links – Tools for styling anchor links. • Lists – Tools for styling lists. • Text – Style helpers for your text. • Color – Utilities for working with colors. • General – Generally useful utilities that don't fit elsewhere. • Sprites – Sprite mixins. • Tables – Style helpers for your tables. 9/1/2014 Technical session on Sass 44
  • 45. Sprite example @import "compass/utilities/sprites"; @import "icons/*.png"; body{ background: black; } $hight: icons-sprite-height(student); $width: icons-sprite-width(student); .icons { display: block; height: $hight; width: $width; } @include all-icons-sprites; 9/1/2014 Technical session on Sass 45
  • 46. Any Questions on how to write maintainable css by using sass?
  • 47. Thank you for your patience and participating in this session.