SlideShare ist ein Scribd-Unternehmen logo
1 von 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.

Weitere ähnliche Inhalte

Was ist angesagt?

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
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)Harshita Yadav
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout Rachel Andrew
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!Ana Cidre
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSSdanpaquette
 
Media queries A to Z
Media queries A to ZMedia queries A to Z
Media queries A to ZShameem Reza
 
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
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid LayoutRachel Andrew
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid LayoutRachel Andrew
 
Intro to HTML & CSS
Intro to HTML & CSSIntro to HTML & CSS
Intro to HTML & CSSSyed Sami
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introductionapnwebdev
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers10Clouds
 

Was ist angesagt? (20)

Css to-scss
Css to-scssCss to-scss
Css to-scss
 
Sass
SassSass
Sass
 
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)
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 
CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout CSS Day: CSS Grid Layout
CSS Day: CSS Grid Layout
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
Media queries A to Z
Media queries A to ZMedia queries A to Z
Media queries A to Z
 
Css ppt
Css pptCss ppt
Css ppt
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Introducing CSS Grid Layout
Introducing CSS Grid LayoutIntroducing CSS Grid Layout
Introducing CSS Grid Layout
 
HTML X CSS
HTML X CSSHTML X CSS
HTML X CSS
 
Intro to HTML & CSS
Intro to HTML & CSSIntro to HTML & CSS
Intro to HTML & CSS
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
CSS For Backend Developers
CSS For Backend DevelopersCSS For Backend Developers
CSS For Backend Developers
 
Less presentation
Less presentationLess presentation
Less presentation
 
CSS
CSSCSS
CSS
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
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
 
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
 
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
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
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
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 

Kürzlich hochgeladen (20)

Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
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 🔝✔️✔️
 
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
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
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
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
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...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

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.