SlideShare a Scribd company logo
CSS PREPROCESSOR
“SASS”
By
Adnan Arshad
CSS Preprocessor
What is CSS?
State of CSS
Introduction to SASS
Features of SASS
Outline
SASS (Syntactically Awesome Stylesheets)
CSS Preprocessors
SASS (Syntactically Awesome Stylesheets)
Language  compilation  CSS
Gives more functionality to CSS
Fewer lines of code
What are CSS Preprocessors ?
SASS (Syntactically Awesome Stylesheets)
Create more manageable, reusable, compact style
sheets
Faster development time
Saves from monotony
Programmatic CSS features
Why use preprocessors?
SASS (Syntactically Awesome Stylesheets)
SASS (Syntactically Awesome Stylesheets)
What is CSS ?
What is CSS?
SASS (Syntactically Awesome Stylesheets)
CSS stands for Cascading
Style Sheet. Typical CSS
file is a text file with an
extention.css and
contains a series of
commands or rules.
These rules tell the
HTML how to display.
*To create a style sheet, create a file
using Notepad or Some Text Editor,
save it as a .css document and start
writing the CSS code (see right).
Style.css
body {
font-family:Arial;
background: #000;
}
.container {
text-align:left;
width:1020px;
}
.header {
height:232px;
}
.footer {
width: 100%;
padding:10px;
margin-bottom: 10px;
}
And so on….
HTML Without CSS
SASS (Syntactically Awesome Stylesheets)
“HTML without CSS is like a
piece of candy without a
pretty wrapper.”
Without CSS, HTML elements
typically flow from top to
bottom of the page and
position themselves to the
left by default.
With CSS help, we can create
DIVs to better organize
content and make a Web
page visually appealing.
The Box Model
SASS (Syntactically Awesome Stylesheets)
CSS works on the
box model. A
typical Web page
consists of many
boxes joined
together from top
to bottom. These
boxes can be
stacked, nested,
and can float.
Header
Navigation
Content
Footer
SASS (Syntactically Awesome Stylesheets)
State of CSS
CSS has not aged well.
o Replacing a Color Value in whole project.
o Copying and Pasting a style (Over and Over again).
These are not features, they are nightmares.
Frustration with CSS
SASS (Syntactically Awesome Stylesheets)
.search-nav .container-fluid {
background-color: #eaeaea;
margin-top: -50px; }
.search-nav .container-fluid .container ol li {
vertical-align: middle; }
.search-nav .container-fluid .container ol li i {
color: #ffffff; }
.search-nav .container-fluid .container ol li a {
color: #000000;
text-decoration: none;
vertical-align: middle; }
.search-nav .container-fluid .container ol li a:hover {
color: #e7002e; }
.search-nav .container-fluid .container ol li a:active {
background-color: none;
color: #e7002e; }
.search-nav .container-fluid .container ol li input {
background-color: #848484;
width: 200px;
border: none;
SASS (Syntactically Awesome Stylesheets)
SASS (Syntactically Awesome Stylesheets)
vertical-align: middle;
border-radius: 0;
color: #ffffff;
margin-top: 7px; }
.navigation.container ul li {
vertical-align: middle; }
.navigation.container ul li .active {
background-color: transparent;
color: #e7002e; }
.navigation.container ul li a {
font-weight: bold;
text-transform: uppercase;
color: #000000; }
.navigation.container ul li a:hover {
background-color: #e7002e;
color: #ffffff; }
.navigation.container ul li a:focus {
background-color: transparent;
color: #e7002e; }
Fixing CSS
SASS (Syntactically Awesome Stylesheets)
Make it Intelligent
Make it re-usable
SASS (Syntactically Awesome Stylesheets)
Intro to SASS
Syntactically Awesome Stylesheets (SASS)
o Developed in 2007 by Hampton Catlin.
Serves as:
o Scripting Language
o Preprocessor for CSS
History
SASS (Syntactically Awesome Stylesheets)
SASS compiles into CSS file.
Two formatting conventions
o .SASS
o .SCSS
Function
SASS (Syntactically Awesome Stylesheets)
.SCSS /.SASS
SASS (Syntactically Awesome Stylesheets)
.SCSS
.value {
color:blue;
a {
color:red;
Text-decoration:none;
}
}
.SASS
.value
color:blue
a
color:red
Text-decoration:none
SASS (Syntactically Awesome Stylesheets)
Sass Features
Sass has 5 features:
o Variables
o Nesting
o Mixins
o Partials
o Inheritance
Features
SASS (Syntactically Awesome Stylesheets)
SASS (Syntactically Awesome Stylesheets)
1. Variables
Lets time-travel back to Computer Science
Variables are used to assign value, and declare with “$”
dollar sign:
o Works with hex values, colors, numbers
o No more memorizing Hex values
Variables
SASS (Syntactically Awesome Stylesheets)
$Red: #b94a48;
$LightGray:#808080;
$OuterCircle: 36px;
$InnerCircle: 26px;
$Border-Color: $Red;
$Background-Color: $LightGray;
.error {
border: 1px solid $Border-Color;
Background-color: $Background-Color;
color:$Red;
width: $OuterCircle;
height: $OuterCircle;
}
Variables
SASS (Syntactically Awesome Stylesheets)
SASS (Syntactically Awesome Stylesheets)
2. Nesting
SASS will let you nest your CSS selectors in a way that follows the
same visual hierarchy of your HTML.
Nesting
SASS (Syntactically Awesome Stylesheets)
Output (CSS)
.media-body {
margin: 10px;
}
.media-body h4 {
text-transform: uppercase;
}
.media-body a {
color: #000000;
text-decoration: none;
}
.media-body a:hover {
color: #000000; }
$LinksColor:#000000;
$LinksHoverColor: $LinksColor;
.media-body {
margin: 10px;
h4 {
text-transform: uppercase;
}
a {
color: $LinksColor;
text-decoration: none;
&:hover {
color: $LinksHoverColor;
}
}
}
SASS (Syntactically Awesome Stylesheets)
3. Mixins
Mixin allows you to chunkup CSS declaration to be reusable
with one reference.
@mixin rounded($radius:10px)
{
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
-ms-border-radius: $radius;
border-radius: $radius;
}
.box { @include rounded(); }
Mixins
SASS (Syntactically Awesome Stylesheets)
OUTPUT (CSS)
.box
{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
}
SASS (Syntactically Awesome Stylesheets)
4. Partials
CSS fact of life:
o CSS files can get Long ( and unwieldy).
SASS allows you to create partials files to modularize and
organize your code.
Partials
SASS (Syntactically Awesome Stylesheets)
Visualizing Partials
SASS (Syntactically Awesome Stylesheets)
SASS (Syntactically Awesome Stylesheets)
Visualizing Partials
Create “_header.scss” file name inside your SASS folder.
Reference your created partial file with your “global.scss”
file as:
Inside your “global.scss” file add this line as:
@import ‘_header’ ;
Creating Partials
SASS (Syntactically Awesome Stylesheets)
SASS (Syntactically Awesome Stylesheets)
5. Inheritance
No More Copy and Paste
Inheritance imports the syntax and style from another
section of your sass file.
Inheritance
SASS (Syntactically Awesome Stylesheets)
.message
{
border: 1px #ccc;
padding: 10px;
color: #333;
}
.success
{
@extend .message;
border-color: green;
}
.error
{
@extend .message;
border-color: red;
}
OUTPUT (CSS)
.message, .success, .error
{
border: 1px solid #ccc;
padding: 10px;
color: #333;
}
.success {
border-color: green; }
.error {
border-color: red; }
For learning SASS: http://sass-lang.com/guide
For Online Compiling and Practice:
http://www.sassmeister.com/
References
SASS (Syntactically Awesome Stylesheets)
Questions!
SASS (Syntactically Awesome Stylesheets)
Thank You!

More Related Content

PPTX
CSS Walktrough Internship Course
PPTX
Introduction to SASS
ODP
Deep dive into sass
PDF
CSS and Layout
ODP
Sass presentation
KEY
Intro to SASS CSS
CSS Walktrough Internship Course
Introduction to SASS
Deep dive into sass
CSS and Layout
Sass presentation
Intro to SASS CSS

What's hot (20)

PDF
CSS preprocessor: why and how
ODP
HTML5, CSS, JavaScript Style guide and coding conventions
PPTX
Cascading style sheet part 2
PPTX
SASS - Syntactically Awesome Stylesheet
PPTX
Cascading style sheets - CSS
PDF
Quality Development with CSS3
PPTX
PDF
2 introduction css
PDF
CSS3: Ripe and Ready to Respond
PDF
Intro to css & sass
PPTX
Cascading Style Sheets
PDF
4. Web Technology CSS Basics-1
PPTX
Colors In CSS3
PPTX
LIS3353 SP12 Week 13
PPTX
Less css
PDF
CSS: a rapidly changing world
PDF
[Worskhop Summits] CSS3 Workshop
PPT
Css Founder.com | Cssfounder in
PPT
Html Expression Web
CSS preprocessor: why and how
HTML5, CSS, JavaScript Style guide and coding conventions
Cascading style sheet part 2
SASS - Syntactically Awesome Stylesheet
Cascading style sheets - CSS
Quality Development with CSS3
2 introduction css
CSS3: Ripe and Ready to Respond
Intro to css & sass
Cascading Style Sheets
4. Web Technology CSS Basics-1
Colors In CSS3
LIS3353 SP12 Week 13
Less css
CSS: a rapidly changing world
[Worskhop Summits] CSS3 Workshop
Css Founder.com | Cssfounder in
Html Expression Web
Ad

Similar to SASS Lecture (20)

PPTX
Introduction to sass
PDF
Css preprocessor-140606115334-phpapp01
PPTX
SCSS Implementation
PPTX
Bliblidotcom - SASS Introduction
PDF
Sass that CSS
PDF
Fasten RWD Development with Sass
PDF
SASS, Compass, Gulp, Greensock
PDF
PPTX
Syntactically awesome stylesheets (Sass)
PDF
CSS Workflow. Pre & Post
PPTX
SASS is more than LESS
PDF
Using Sass in Your WordPress Projects
PDF
Intro to Sass for WordPress Developers
PDF
Assembling Sass
PDF
European SharePoint Webinar - Make SharePoint Sassy
PDF
Atlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass Topics
PPTX
SPS Belgium - Stop your SharePoint CSS becoming a di-SASS-ter today!
PPTX
Stop your sharepoint css becoming a disasster today spsbe2015
PDF
Getting SASSy with front end development
PDF
SASS In The Real World
Introduction to sass
Css preprocessor-140606115334-phpapp01
SCSS Implementation
Bliblidotcom - SASS Introduction
Sass that CSS
Fasten RWD Development with Sass
SASS, Compass, Gulp, Greensock
Syntactically awesome stylesheets (Sass)
CSS Workflow. Pre & Post
SASS is more than LESS
Using Sass in Your WordPress Projects
Intro to Sass for WordPress Developers
Assembling Sass
European SharePoint Webinar - Make SharePoint Sassy
Atlanta Drupal User's Group - April 2015 - Sasstronauts: Advanced Sass Topics
SPS Belgium - Stop your SharePoint CSS becoming a di-SASS-ter today!
Stop your sharepoint css becoming a disasster today spsbe2015
Getting SASSy with front end development
SASS In The Real World
Ad

SASS Lecture

  • 2. CSS Preprocessor What is CSS? State of CSS Introduction to SASS Features of SASS Outline SASS (Syntactically Awesome Stylesheets)
  • 4. Language  compilation  CSS Gives more functionality to CSS Fewer lines of code What are CSS Preprocessors ? SASS (Syntactically Awesome Stylesheets)
  • 5. Create more manageable, reusable, compact style sheets Faster development time Saves from monotony Programmatic CSS features Why use preprocessors? SASS (Syntactically Awesome Stylesheets)
  • 6. SASS (Syntactically Awesome Stylesheets) What is CSS ?
  • 7. What is CSS? SASS (Syntactically Awesome Stylesheets) CSS stands for Cascading Style Sheet. Typical CSS file is a text file with an extention.css and contains a series of commands or rules. These rules tell the HTML how to display. *To create a style sheet, create a file using Notepad or Some Text Editor, save it as a .css document and start writing the CSS code (see right). Style.css body { font-family:Arial; background: #000; } .container { text-align:left; width:1020px; } .header { height:232px; } .footer { width: 100%; padding:10px; margin-bottom: 10px; } And so on….
  • 8. HTML Without CSS SASS (Syntactically Awesome Stylesheets) “HTML without CSS is like a piece of candy without a pretty wrapper.” Without CSS, HTML elements typically flow from top to bottom of the page and position themselves to the left by default. With CSS help, we can create DIVs to better organize content and make a Web page visually appealing.
  • 9. The Box Model SASS (Syntactically Awesome Stylesheets) CSS works on the box model. A typical Web page consists of many boxes joined together from top to bottom. These boxes can be stacked, nested, and can float. Header Navigation Content Footer
  • 10. SASS (Syntactically Awesome Stylesheets) State of CSS
  • 11. CSS has not aged well. o Replacing a Color Value in whole project. o Copying and Pasting a style (Over and Over again). These are not features, they are nightmares. Frustration with CSS SASS (Syntactically Awesome Stylesheets)
  • 12. .search-nav .container-fluid { background-color: #eaeaea; margin-top: -50px; } .search-nav .container-fluid .container ol li { vertical-align: middle; } .search-nav .container-fluid .container ol li i { color: #ffffff; } .search-nav .container-fluid .container ol li a { color: #000000; text-decoration: none; vertical-align: middle; } .search-nav .container-fluid .container ol li a:hover { color: #e7002e; } .search-nav .container-fluid .container ol li a:active { background-color: none; color: #e7002e; } .search-nav .container-fluid .container ol li input { background-color: #848484; width: 200px; border: none; SASS (Syntactically Awesome Stylesheets)
  • 13. SASS (Syntactically Awesome Stylesheets) vertical-align: middle; border-radius: 0; color: #ffffff; margin-top: 7px; } .navigation.container ul li { vertical-align: middle; } .navigation.container ul li .active { background-color: transparent; color: #e7002e; } .navigation.container ul li a { font-weight: bold; text-transform: uppercase; color: #000000; } .navigation.container ul li a:hover { background-color: #e7002e; color: #ffffff; } .navigation.container ul li a:focus { background-color: transparent; color: #e7002e; }
  • 14. Fixing CSS SASS (Syntactically Awesome Stylesheets) Make it Intelligent Make it re-usable
  • 15. SASS (Syntactically Awesome Stylesheets) Intro to SASS
  • 16. Syntactically Awesome Stylesheets (SASS) o Developed in 2007 by Hampton Catlin. Serves as: o Scripting Language o Preprocessor for CSS History SASS (Syntactically Awesome Stylesheets)
  • 17. SASS compiles into CSS file. Two formatting conventions o .SASS o .SCSS Function SASS (Syntactically Awesome Stylesheets)
  • 18. .SCSS /.SASS SASS (Syntactically Awesome Stylesheets) .SCSS .value { color:blue; a { color:red; Text-decoration:none; } } .SASS .value color:blue a color:red Text-decoration:none
  • 19. SASS (Syntactically Awesome Stylesheets) Sass Features
  • 20. Sass has 5 features: o Variables o Nesting o Mixins o Partials o Inheritance Features SASS (Syntactically Awesome Stylesheets)
  • 21. SASS (Syntactically Awesome Stylesheets) 1. Variables Lets time-travel back to Computer Science
  • 22. Variables are used to assign value, and declare with “$” dollar sign: o Works with hex values, colors, numbers o No more memorizing Hex values Variables SASS (Syntactically Awesome Stylesheets)
  • 23. $Red: #b94a48; $LightGray:#808080; $OuterCircle: 36px; $InnerCircle: 26px; $Border-Color: $Red; $Background-Color: $LightGray; .error { border: 1px solid $Border-Color; Background-color: $Background-Color; color:$Red; width: $OuterCircle; height: $OuterCircle; } Variables SASS (Syntactically Awesome Stylesheets)
  • 24. SASS (Syntactically Awesome Stylesheets) 2. Nesting
  • 25. SASS will let you nest your CSS selectors in a way that follows the same visual hierarchy of your HTML. Nesting SASS (Syntactically Awesome Stylesheets) Output (CSS) .media-body { margin: 10px; } .media-body h4 { text-transform: uppercase; } .media-body a { color: #000000; text-decoration: none; } .media-body a:hover { color: #000000; } $LinksColor:#000000; $LinksHoverColor: $LinksColor; .media-body { margin: 10px; h4 { text-transform: uppercase; } a { color: $LinksColor; text-decoration: none; &:hover { color: $LinksHoverColor; } } }
  • 26. SASS (Syntactically Awesome Stylesheets) 3. Mixins
  • 27. Mixin allows you to chunkup CSS declaration to be reusable with one reference. @mixin rounded($radius:10px) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius; } .box { @include rounded(); } Mixins SASS (Syntactically Awesome Stylesheets) OUTPUT (CSS) .box { -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; border-radius: 10px; }
  • 28. SASS (Syntactically Awesome Stylesheets) 4. Partials
  • 29. CSS fact of life: o CSS files can get Long ( and unwieldy). SASS allows you to create partials files to modularize and organize your code. Partials SASS (Syntactically Awesome Stylesheets)
  • 31. SASS (Syntactically Awesome Stylesheets) Visualizing Partials
  • 32. Create “_header.scss” file name inside your SASS folder. Reference your created partial file with your “global.scss” file as: Inside your “global.scss” file add this line as: @import ‘_header’ ; Creating Partials SASS (Syntactically Awesome Stylesheets)
  • 33. SASS (Syntactically Awesome Stylesheets) 5. Inheritance No More Copy and Paste
  • 34. Inheritance imports the syntax and style from another section of your sass file. Inheritance SASS (Syntactically Awesome Stylesheets) .message { border: 1px #ccc; padding: 10px; color: #333; } .success { @extend .message; border-color: green; } .error { @extend .message; border-color: red; } OUTPUT (CSS) .message, .success, .error { border: 1px solid #ccc; padding: 10px; color: #333; } .success { border-color: green; } .error { border-color: red; }
  • 35. For learning SASS: http://sass-lang.com/guide For Online Compiling and Practice: http://www.sassmeister.com/ References
  • 36. SASS (Syntactically Awesome Stylesheets) Questions!
  • 37. SASS (Syntactically Awesome Stylesheets) Thank You!