SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
CSS Preprocessor:
Why and How
M. Mizanur Rahman
A love letter from CSS
Frustrations with CSS
• It looks messy
• Repetitive
• Tendency of copy pasting over and over
• Big chunk of codes
• Vendor specific prefixes
• Not DRY Enough
What if CSS gets a new look
• It becomes re-usable
• It becomes scalable
• It becomes smart
• It understand a programmers mind
What is a Preprocessor?
• Have you heard the word “Preprocessor” for first time?
• CSS preprocessors take code written in the preprocessed
language and then convert that code into the same old css
we’ve been writing for years
• Preprocessors are not CSS, so CSS weaknesses do not belong
to them
• At the end, the output will be pure CSS files. So it does not
matter what Preprocessor you use in your project
Some Popular Preprocessors
• SASS
• LESS
• Stylus
Which one to Choose
• 80% of the SASS, LESS and Stylus are same
• 20% are different based on their advanced features and usage
• The similar features are
• Variables
• Color Transformation
• Mixings
• Nesting
• Loops and conditions
• Import
Let’s Focus on SASS
• SASS - Syntactically Awesome StyleSheets
• Sass is an extension of CSS that adds power and elegance to the basic
language. It allows you to use variables, nested rules, mixins, inline
imports, and more, all with a fully CSS-compatible syntax.
• Features
• Fully CSS3-compatible
• Language extensions such as variables, nesting, and mixins
• Many useful functions for manipulating colors and other values
• Advanced features like control directives for libraries
• Well-formatted, customizable output
• Firebug integration
SASS or SCSS??
• There are two syntaxes available for Sass.
• First and latest one known as SCSS (Sassy CSS) and is an extension of
the syntax of CSS3. This means that every valid CSS3 stylesheet is a
valid SCSS file with the same meaning.
• Files have .scss extension
• It uses brackets and semi-colons just like CSS
• Easy to pickup by the developers
• SASS is the old style syntax.
• Focus on indented syntax
• Have .sass file extension
• Not so well picked by developers for different syntax from CSS
SASS & SCSS samples
$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-color
H1
color: $primary-color
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
H1 {
color: $primary-color;
}
How to Install SASS
• Requires Ruby to be installed on developer machine (Not
server)
gem install sass
sass -v
You can also use the following applications
• Compass
• Koala
• Scout
SASS Features: Variables
• Starts with $ sign
• allows you to assign a value to an easy-to-
remember placeholder name
• Allows:
• numbers (e.g. 1.2, 13, 10px)
• strings of text, with and without quotes
(e.g. "foo", 'bar', baz)
• colors (e.g. blue, #04a3f9, rgba(255, 0, 0, 0.5))
• booleans (e.g. true, false)
• nulls (e.g. null)
• lists of values, separated by spaces or commas
(e.g. 1.5em 1em 0 2em, Helvetica, Arial, sans-serif)
• maps from one value to another (e.g. (key1: value1,
key2: value2))
$width: 5em;
#main { width: $width; }
.label {font-size: $width;}
Converts to
#main {width: 5em; }
.label {font-size: 5em; }
Nesting
/* -- scss -- */
$background: #f0f0f0;
#navbar {
width: 100%;
height: 30px;
padding: 10px;
background: $background;
ul {
list-style: none;
}
li {
float: left;
a { text-decoration: none; }
&:hover { text-decoration: underline; } }
}
/* -- resulting css -- */
#navbar {width: 100%; height:
30px;padding:10px; background:
#f0f0f0}
#navbar ul {list-style: none;}
#navbar li {float: left;}
#navbar li a {text-decoration: none;}
#navbar li a:hover {text-decoration:
underline;}
Interpolation
• You can also use SASS variables in
selectors and property names using
#{} interpolation syntax
$name: foo;
$attr: border;
p.#{$name} {
#{$attr}-color: blue;
}
Outputs
p.foo { border-color: blue; }
Operations
• Number Operations
• Color Operations
• String Operations
• Boolean Operations
• List Operations
• Parentheses
$navbar-width: 950px;
$items: 5;
#navbar li {
width: $navbar-width/$items - 10px;}
p { color: #010203 + #040506; }
p { cursor: e + -resize; }
p { width: 1em + (2em * 3); }
--------------------- Output ------
-----------------
#navbar li {width: 180px}
p { color: #050709; }
p { cursor: e-resize; }
p { width: 7em; }
Mixins
• Mixins allow you to chunk up CSS
declarations (block of rules) to be reusable
with one reference
• Mixins are included in the document with
the @include directive. It also takes optional
arguments.
@mixin rounded-corners {
$radius: 5px;
border-radius: $radius;
-webkit-border-radius: $radius;
-moz-border-radius: $radius; }
#header { @include rounded-corners; }
#footer { @include rounded-corners; }
---------------- Output ------------------------
#header {
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
#footer {
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
}
Mixins (With Argument)
@mixin my-border($color, $width) {
border: {
color: $color;
width: $width;
style: dashed; }
}
p { @include my-border(red, 1px); }
p {
border-color: red;
border-width: 1px;
border-style: dashed;
}
Converting SASS files to CSS files
sass input.scss output.css
Partials & Imports
• Divide a big SASS file to
smaller SASS files
• Start with a underscore
_example.scss
• Can be reused in different
projects (eg: _table.scss,
_form.scss etc)
• When converted to CSS,
partials files are not
generated to any css files.
• @import “form"; will
import _form.scss
Extend/Inheritance
• One of the most important feature of SASS
• @extend lets you share a set of CSS properties from one
selector to another
• It helps to prevent repetition in our SASS files.
.message {
border: 1px solid #ccc;
padding: 10px;
color: #444; }
.success {
@extend .message;
border-color: green;}
.error {
@extend .message;
border-color: red; }
.warning {
@extend .message;
border-color: orange; }
-------------- Output -------------------------
.message, .success, .error, .warning {
border: 1px solid #cccccc;
padding: 10px;
color: #444; }
.success { border-color: green; }
.error { border-color: red; }
.warning { border-color: orange; }
Looking for More?
• Go through SASS based frameworks
• Compass
• Bourbon
• Susy
• OOCSS (Object Oriented CSS)
• There are some great paid apps for SASS
• CodeKit
• Hammer
• Mixture
• LiveReload
• Prepros
About Me 
M. Mizanur Rahman
Development Manager, TrustPilot Bangladesh
GraphicPeople
Moderator PHPXperts
Email: mizanur.rahman@gmail.com
Blog: http://booleandreams.wordpress.com

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASSJon Dean
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sasschriseppstein
 
[Worskhop Summits] CSS3 Workshop
[Worskhop Summits] CSS3 Workshop[Worskhop Summits] CSS3 Workshop
[Worskhop Summits] CSS3 WorkshopChristopher Schmitt
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondDenise Jacobs
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Startededgincvg
 
October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101Eric Sembrat
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
CSS3: Simply Responsive
CSS3: Simply ResponsiveCSS3: Simply Responsive
CSS3: Simply ResponsiveDenise Jacobs
 
CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship CourseZoltan Iszlai
 

Was ist angesagt? (20)

Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
Sass
SassSass
Sass
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Compass/Sass
Compass/SassCompass/Sass
Compass/Sass
 
CSS3
CSS3CSS3
CSS3
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
 
[Worskhop Summits] CSS3 Workshop
[Worskhop Summits] CSS3 Workshop[Worskhop Summits] CSS3 Workshop
[Worskhop Summits] CSS3 Workshop
 
CSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to RespondCSS3: Ripe and Ready to Respond
CSS3: Ripe and Ready to Respond
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
SASS Lecture
SASS Lecture SASS Lecture
SASS Lecture
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
CSS
CSSCSS
CSS
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
Css 3
Css 3Css 3
Css 3
 
Css 3
Css 3Css 3
Css 3
 
October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101October 2014 - USG Rock Eagle - Sass 101
October 2014 - USG Rock Eagle - Sass 101
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
CSS3: Simply Responsive
CSS3: Simply ResponsiveCSS3: Simply Responsive
CSS3: Simply Responsive
 
CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship Course
 

Ähnlich wie Css preprocessor-140606115334-phpapp01

Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingJames Cryer
 
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, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Tahmina Khatoon
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sassKnoldus Inc.
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageKatsunori Tanaka
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)emrox
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3 Wynn Netherland
 
Raleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass PresentationRaleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass PresentationDaniel Yuschick
 
2 introduction css
2 introduction css2 introduction css
2 introduction cssJalpesh Vasa
 

Ähnlich wie Css preprocessor-140606115334-phpapp01 (20)

Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y trying
 
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, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)
 
Why less?
Why less?Why less?
Why less?
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
PostCss
PostCssPostCss
PostCss
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
Sass compass
Sass compassSass compass
Sass compass
 
Less css
Less cssLess css
Less css
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Understanding sass
Understanding sassUnderstanding sass
Understanding sass
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
Raleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass PresentationRaleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass Presentation
 
2 introduction css
2 introduction css2 introduction css
2 introduction css
 

Kürzlich hochgeladen

Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Call Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full NightCall Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full Nightssuser7cb4ff
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造kbdhl05e
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一z xss
 
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`dajasot375
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书zdzoqco
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVAAnastasiya Kudinova
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxmapanig881
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)jennyeacort
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfAayushChavan5
 
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCRdollysharma2066
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档208367051
 
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一Fi sss
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...katerynaivanenko1
 
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degreeyuu sss
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfShivakumar Viswanathan
 
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证nhjeo1gg
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Sitegalleryaagency
 

Kürzlich hochgeladen (20)

Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
原版美国亚利桑那州立大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Call Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full NightCall Girls Aslali 7397865700 Ridhima Hire Me Full Night
Call Girls Aslali 7397865700 Ridhima Hire Me Full Night
 
西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造西北大学毕业证学位证成绩单-怎么样办伪造
西北大学毕业证学位证成绩单-怎么样办伪造
 
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
办理(UC毕业证书)查尔斯顿大学毕业证成绩单原版一比一
 
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
Abu Dhabi Call Girls O58993O4O2 Call Girls in Abu Dhabi`
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
 
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
PORTAFOLIO   2024_  ANASTASIYA  KUDINOVAPORTAFOLIO   2024_  ANASTASIYA  KUDINOVA
PORTAFOLIO 2024_ ANASTASIYA KUDINOVA
 
Untitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptxUntitled presedddddddddddddddddntation (1).pptx
Untitled presedddddddddddddddddntation (1).pptx
 
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
Call Us ✡️97111⇛47426⇛Call In girls Vasant Vihar༒(Delhi)
 
Pharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdfPharmaceutical Packaging for the elderly.pdf
Pharmaceutical Packaging for the elderly.pdf
 
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
8377877756 Full Enjoy @24/7 Call Girls in Nirman Vihar Delhi NCR
 
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
昆士兰大学毕业证(UQ毕业证)#文凭成绩单#真实留信学历认证永久存档
 
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Okhla Delhi 💯Call Us 🔝8264348440🔝
 
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
(办理学位证)埃迪斯科文大学毕业证成绩单原版一比一
 
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
MT. Marseille an Archipelago. Strategies for Integrating Residential Communit...
 
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
专业一比一美国亚利桑那大学毕业证成绩单pdf电子版制作修改#真实工艺展示#真实防伪#diploma#degree
 
FiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdfFiveHypotheses_UIDMasterclass_18April2024.pdf
FiveHypotheses_UIDMasterclass_18April2024.pdf
 
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
在线办理ohio毕业证俄亥俄大学毕业证成绩单留信学历认证
 
How to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our SiteHow to Be Famous in your Field just visit our Site
How to Be Famous in your Field just visit our Site
 

Css preprocessor-140606115334-phpapp01

  • 1. CSS Preprocessor: Why and How M. Mizanur Rahman
  • 2. A love letter from CSS
  • 3. Frustrations with CSS • It looks messy • Repetitive • Tendency of copy pasting over and over • Big chunk of codes • Vendor specific prefixes • Not DRY Enough
  • 4. What if CSS gets a new look • It becomes re-usable • It becomes scalable • It becomes smart • It understand a programmers mind
  • 5. What is a Preprocessor? • Have you heard the word “Preprocessor” for first time? • CSS preprocessors take code written in the preprocessed language and then convert that code into the same old css we’ve been writing for years • Preprocessors are not CSS, so CSS weaknesses do not belong to them • At the end, the output will be pure CSS files. So it does not matter what Preprocessor you use in your project
  • 6. Some Popular Preprocessors • SASS • LESS • Stylus
  • 7. Which one to Choose • 80% of the SASS, LESS and Stylus are same • 20% are different based on their advanced features and usage • The similar features are • Variables • Color Transformation • Mixings • Nesting • Loops and conditions • Import
  • 8. Let’s Focus on SASS • SASS - Syntactically Awesome StyleSheets • Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. • Features • Fully CSS3-compatible • Language extensions such as variables, nesting, and mixins • Many useful functions for manipulating colors and other values • Advanced features like control directives for libraries • Well-formatted, customizable output • Firebug integration
  • 9. SASS or SCSS?? • There are two syntaxes available for Sass. • First and latest one known as SCSS (Sassy CSS) and is an extension of the syntax of CSS3. This means that every valid CSS3 stylesheet is a valid SCSS file with the same meaning. • Files have .scss extension • It uses brackets and semi-colons just like CSS • Easy to pickup by the developers • SASS is the old style syntax. • Focus on indented syntax • Have .sass file extension • Not so well picked by developers for different syntax from CSS
  • 10. SASS & SCSS samples $font-stack: Helvetica, sans-serif $primary-color: #333 body font: 100% $font-stack color: $primary-color H1 color: $primary-color $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } H1 { color: $primary-color; }
  • 11. How to Install SASS • Requires Ruby to be installed on developer machine (Not server) gem install sass sass -v You can also use the following applications • Compass • Koala • Scout
  • 12. SASS Features: Variables • Starts with $ sign • allows you to assign a value to an easy-to- remember placeholder name • Allows: • numbers (e.g. 1.2, 13, 10px) • strings of text, with and without quotes (e.g. "foo", 'bar', baz) • colors (e.g. blue, #04a3f9, rgba(255, 0, 0, 0.5)) • booleans (e.g. true, false) • nulls (e.g. null) • lists of values, separated by spaces or commas (e.g. 1.5em 1em 0 2em, Helvetica, Arial, sans-serif) • maps from one value to another (e.g. (key1: value1, key2: value2)) $width: 5em; #main { width: $width; } .label {font-size: $width;} Converts to #main {width: 5em; } .label {font-size: 5em; }
  • 13. Nesting /* -- scss -- */ $background: #f0f0f0; #navbar { width: 100%; height: 30px; padding: 10px; background: $background; ul { list-style: none; } li { float: left; a { text-decoration: none; } &:hover { text-decoration: underline; } } } /* -- resulting css -- */ #navbar {width: 100%; height: 30px;padding:10px; background: #f0f0f0} #navbar ul {list-style: none;} #navbar li {float: left;} #navbar li a {text-decoration: none;} #navbar li a:hover {text-decoration: underline;}
  • 14. Interpolation • You can also use SASS variables in selectors and property names using #{} interpolation syntax $name: foo; $attr: border; p.#{$name} { #{$attr}-color: blue; } Outputs p.foo { border-color: blue; }
  • 15. Operations • Number Operations • Color Operations • String Operations • Boolean Operations • List Operations • Parentheses $navbar-width: 950px; $items: 5; #navbar li { width: $navbar-width/$items - 10px;} p { color: #010203 + #040506; } p { cursor: e + -resize; } p { width: 1em + (2em * 3); } --------------------- Output ------ ----------------- #navbar li {width: 180px} p { color: #050709; } p { cursor: e-resize; } p { width: 7em; }
  • 16. Mixins • Mixins allow you to chunk up CSS declarations (block of rules) to be reusable with one reference • Mixins are included in the document with the @include directive. It also takes optional arguments. @mixin rounded-corners { $radius: 5px; border-radius: $radius; -webkit-border-radius: $radius; -moz-border-radius: $radius; } #header { @include rounded-corners; } #footer { @include rounded-corners; } ---------------- Output ------------------------ #header { border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; } #footer { border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; }
  • 17. Mixins (With Argument) @mixin my-border($color, $width) { border: { color: $color; width: $width; style: dashed; } } p { @include my-border(red, 1px); } p { border-color: red; border-width: 1px; border-style: dashed; }
  • 18. Converting SASS files to CSS files sass input.scss output.css
  • 19. Partials & Imports • Divide a big SASS file to smaller SASS files • Start with a underscore _example.scss • Can be reused in different projects (eg: _table.scss, _form.scss etc) • When converted to CSS, partials files are not generated to any css files. • @import “form"; will import _form.scss
  • 20. Extend/Inheritance • One of the most important feature of SASS • @extend lets you share a set of CSS properties from one selector to another • It helps to prevent repetition in our SASS files. .message { border: 1px solid #ccc; padding: 10px; color: #444; } .success { @extend .message; border-color: green;} .error { @extend .message; border-color: red; } .warning { @extend .message; border-color: orange; } -------------- Output ------------------------- .message, .success, .error, .warning { border: 1px solid #cccccc; padding: 10px; color: #444; } .success { border-color: green; } .error { border-color: red; } .warning { border-color: orange; }
  • 21. Looking for More? • Go through SASS based frameworks • Compass • Bourbon • Susy • OOCSS (Object Oriented CSS) • There are some great paid apps for SASS • CodeKit • Hammer • Mixture • LiveReload • Prepros
  • 22. About Me  M. Mizanur Rahman Development Manager, TrustPilot Bangladesh GraphicPeople Moderator PHPXperts Email: mizanur.rahman@gmail.com Blog: http://booleandreams.wordpress.com