SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
10
   2102 HT81 REBOTCO , NOIT NEV NOC I NMULA EAS
CSS PREPROCESSORS
O T N OI T CU D O R TNI N A
O T N OI T CU D O R TNI N A
O R TNI K CIU Q
              O R TNI K CIU Q
                             EM TUOBA
                             EM TUOBA



Milos Sutanovac
Front-End Engineer
Uhm… something with code & design, I guess?
JavaScript, HTML5, CSS3 @ SAE Munich
Bachelor of Arts, Web Development
twitter.com/mixn
?TAHT SI YLTCAXE TAHW
      ?TAHT SI YLTCAXE TAHW
” R OSS E C O RP E RP “
” R OSS E C O RP E RP “
…WONK UO Y
…WONK UO Y
AI D EPI KI W
                AI D EPI KI W

“ In computer science, a preprocessor is a program that processes
   its input data to produce output that is used as input to another
                       program. [...] — Wikipedia ”
” R OSS E C O RP E RP SS C “
” R OSS E C O RP E RP SS C “
Extension to CSS, which compiles to regular CSS
Superset
More functionalities
Outputs regular, cross-browser code
No limitations, since not regular CSS
Makes CSS more flexible & fun to write (again)
ROSSECOR PER P .SV SSC
       ROSSECOR PER P .SV SSC
N OSI R AP M O C K CI U Q
N OSI R AP M O C K CI U Q
SS C
                         SS C
No expressions or math
wdh 5*(0p +2;/ 50x Wsfltikn *
it:    10x ) * 1p? ihu hnig /


No logic
Lack of variables
Lack of abstraction
@motul'yorpycs)
ipr r(tpgah.s';
@motul'ics)
ipr r(u.s';

/ EtaHT rqet *
 * xr TP euss /


Vendor Prefix Hell
S R OSS E C O RP E RP
        S R OSS E C O RP E RP
Cleaner, shorter syntax
Variables
Interpolation
Nesting
Expressions & Calculations
Mixins, Imports, Functions, Statements, Includes, Inheritance, Loops, Logic …
U
     SULYTS ,SSAS ,SSEL
S N OI T C NI TSI D
S N OI T C NI TSI D
 & S E CI O H C
 & S E CI O H C
”EGAUG NAL TEEHSELYTS CIMA NYD EHT“
             ”EGAUG NAL TEEHSELYTS CIMA NYD EHT“



Alexis Sellier
lesscss.org
Originally in Ruby, deprecated & replaced by JavaScript
.less
Installation
nmisalls
p ntl es
ls syels
es tl.es


Syntax example
@oo:#0FE
clr CFE;

.igt{
 wde
  bcgon:@oo;
   akrud clr
}
”EDUTITTA HTIW ELYTS“
                     ”EDUTITTA HTIW ELYTS“



Hampton Catlin, Nathan Weizenbaum & Chris Eppstein
sass-lang.com
Written in Ruby
.scss, .sass
Installation
gmisalss
 e ntl as
m syecssyess
 v tl.s tl.cs
ss syess syecs
 as tl.cs tl.s
ss -wthsyess
 as -ac tl.as


Syntax example
$oo:#0FE
clr CFE;

.igt{
 wde
  bcgon:$oo;
   akrud clr
}
”SSC TSUBOR ,CIMA NYD ,EVISSER PXE“
               ”SSC TSUBOR ,CIMA NYD ,EVISSER PXE“



TJ Holowaychuk
learnboost.github.com/stylus
Written in JavaScript
.styl
Installation
nmisalsyu
p ntl tls
syu - syesy
tls c tl.tl


Syntax example
clr=#0FE
oo   CFE

.igt
wde
 clrclr
  oo oo
SSEL G NISU ,SUOIRUC UOY G NI KAM
    SSEL G NISU ,SUOIRUC UOY G NI KAM
N WO DNU R E RU TA E F
N WO DNU R E RU TA E F
& S EL B AI R A V
           & S EL B AI R A V

       N OI T AL OP R E TNI
       N OI T AL OP R E TNI
@rmrClr #ffb
 piayoo: ffd;
@mPt:'.ig'
 igah ./m/;

.igt{
 wde
  bcgon:ul'{mPt}edrb.n' rpa-;
  akrud r(@igahhae_gpg) eetx
  clr @rmrClr
  oo: piayoo;
}
G NI TS E N
                     G NI TS E N
@otie 10;
 fnSz: 6%

nv{
 a
  fn-ie @otie
   otsz: fnSz;
  l {
   i
    fot lf;
     la: et
    a{
      dsly iln-lc;
       ipa: niebok
      &hvr{
       :oe
        clr htik
         oo: opn;
      }
    }
  }
}


Dangerous, can result in code bloat
Preprocessing or not, embrace things like SMACSS & OOCSS
CSS structure !== HTML structure
Inception rule: don’t go more than four levels deep
& S N OISS E RP X E
        & S N OISS E RP X E

         SN OI T ALU CL A C
         SN OI T ALU CL A C
@o:5;
 fo %
@a:@o *2 / 5 *2=1%
 br fo   ; / %   0
@abz (br+@o)*5 / (0 +5)*5=7%
 fza: @a    fo ; / 1% %    5

.igt{
 wde
  wdh @abz-2;/ 7%-2 =5%
  it: fza   5 / 5  5  0
}
SNIXI M
                        SNIXI M
.nmtd{
 aiae
  -ektaiain ple.ses-n
  wbi-nmto: us 5 aei;
  -o-nmto:ple.ses-n
  mzaiain us 5 aei;
  -saiain ple.ses-n
  m-nmto: us 5 aei;
  --nmto:ple.ses-n
  oaiain us 5 aei;
  aiain ple.ses-n
  nmto: us 5 aei;
}

.nmtdwde {
 aiae_igt
  .nmtd
  aiae;
}


Can have parameters (with default values)
.nmtd(tmnFnto:lna){
 aiae @iigucin ier
  -ektaiain ple.s@iigucin
   wbi-nmto: us 5 tmnFnto;
  -o-nmto:ple.s@iigucin
   mzaiain us 5 tmnFnto;
  -saiain ple.s@iigucin
   m-nmto: us 5 tmnFnto;
  --nmto:ple.s@iigucin
   oaiain us 5 tmnFnto;
  aiain ple.s@iigucin
   nmto: us 5 tmnFnto;
}

.nmtdwde {
 aiae_igt
  .nmtd
   aiae;
}

.nte_nmtdwde {
 aohraiae_igt
  .nmtdes-n;
   aiae(aei)
}
S T R OP MI
                     S T R OP MI
/ Isedo ti
 / nta f hs
@motul'yorpycs)
 ipr r(tpgah.s';

/ D ti
 / o hs
@mot'yorpycs;
 ipr tpgah.s'


No extra HTTP request
Concatination behind the scenes
SN OI T CNU F
                 SN OI T CNU F
lgtn@oo,1%;
 ihe(clr 0)        / rtr aclrwihi 1%lgtrta @oo
                    / eun  oo hc s 0 ihe hn clr
dre(clr 1%;
 akn@oo, 0)        / rtr aclrwihi 1%dre ta @oo
                    / eun  oo hc s 0 akr hn clr

strt(clr 1%;
 auae@oo, 0)  / rtr aclr1%mr strtdta @oo
               / eun  oo 0 oe auae hn clr
dstrt(clr 1%; / rtr aclr1%ls strtdta @oo
 eauae@oo, 0)  / eun  oo 0 es auae hn clr

fdi(clr 1%;
 aen@oo, 0)        / rtr aclr1%ls tasaetta @oo
                    / eun  oo 0 es rnprn hn clr
fdot@oo,1%;
 aeu(clr 0)        / rtr aclr1%mr tasaetta @oo
                    / eun  oo 0 oe rnprn hn clr
fd(clr 5%;
 ae@oo, 0)         / rtr @oo wt 5%tasaec
                    / eun clr ih 0 rnprny

si(clr 1)
 pn@oo, 0;         / rtr aclrwt a1 dge lre i heta @oo
                    / eun  oo ih  0 ere agr n u hn clr
si(clr -0;
 pn@oo, 1)         / rtr aclrwt a1 dge salrheta @oo
                    / eun  oo ih  0 ere mle u hn clr

mx@oo1 @oo2;
 i(clr, clr)       / rtr amxo @oo1ad@oo2
                    / eun  i f clr n clr


Sass & Stylus offer even more
CI G O L & S T N E M E T A TS
 CI G O L & S T N E M E T A TS
if, else, for, each, while
Programming logic applied to CSS
http://thesassway.com/intermediate/if-for-each-while
S K C A B W A R D E M OS
     S K C A B W A R D E M OS
                  TCEFRE P SI G NIHTO N ESUACEB
                  TCEFRE P SI G NIHTO N ESUACEB



Working on a team
Editing the compiled .css file
Increases room for errors
Potential code bloat
Choice?
Not without a learning curve — but what is?
Command Line
   Can be avoided: CodeKit , LiveReload , Compass.app , SCOUT
   Learn it — it’s the most powerful tool you have
  “ Learn to love the command line. It isn’t scary. You know how to use
    Photoshop which has 300 buttons — THAT’S scary. — Stephen Hay ”
NOIT NETTA RUOY ROF
 NOIT NETTA RUOY ROF
UO Y KNAH T
UO Y KNAH T
CSS Preprocessors: Cleaner Code & More Powerful Stylesheets

Weitere ähnliche Inhalte

Ähnlich wie CSS Preprocessors: Cleaner Code & More Powerful Stylesheets

Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaTony Fabeen
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scriptingTony Fabeen
 
Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and ProfitNicholas Jansma
 
Writing (Meteor) Code With Style
Writing (Meteor) Code With StyleWriting (Meteor) Code With Style
Writing (Meteor) Code With StyleStephan Hochhaus
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleAri Lerner
 
PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!Blanca Mancilla
 
Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015Sawood Alam
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and mythsWojciech Sznapka
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate WorksGoro Fuji
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaAlexander Gyoshev
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAjeet Singh Raina
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamHenryk Konsek
 
WordPress in 30 minutes
WordPress in 30 minutesWordPress in 30 minutes
WordPress in 30 minutesOwen Winkler
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best PracticesEdorian
 
Microservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud NetflixMicroservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud NetflixKrzysztof Sobkowiak
 
Learn Frontend Testing
Learn Frontend TestingLearn Frontend Testing
Learn Frontend TestingRyan Roemer
 
Theme Development and Customization
Theme Development and CustomizationTheme Development and Customization
Theme Development and CustomizationAniket Pant
 

Ähnlich wie CSS Preprocessors: Cleaner Code & More Powerful Stylesheets (20)

JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Nginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with LuaNginx Scripting - Extending Nginx Functionalities with Lua
Nginx Scripting - Extending Nginx Functionalities with Lua
 
Devinsampa nginx-scripting
Devinsampa nginx-scriptingDevinsampa nginx-scripting
Devinsampa nginx-scripting
 
Using Phing for Fun and Profit
Using Phing for Fun and ProfitUsing Phing for Fun and Profit
Using Phing for Fun and Profit
 
Writing (Meteor) Code With Style
Writing (Meteor) Code With StyleWriting (Meteor) Code With Style
Writing (Meteor) Code With Style
 
Beginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at GoogleBeginner workshop to angularjs presentation at Google
Beginner workshop to angularjs presentation at Google
 
PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!PyLadies Talk: Learn to love the command line!
PyLadies Talk: Learn to love the command line!
 
Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015Profiling Web Archives IIPC GA 2015
Profiling Web Archives IIPC GA 2015
 
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
 
How Xslate Works
How Xslate WorksHow Xslate Works
How Xslate Works
 
Building modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and javaBuilding modern web apps with html5, javascript, and java
Building modern web apps with html5, javascript, and java
 
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar PradhanAwesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
Awesome Traefik - Ingress Controller for Kubernetes - Swapnasagar Pradhan
 
Testing Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax ExamTesting Fuse Fabric with Pax Exam
Testing Fuse Fabric with Pax Exam
 
WordPress in 30 minutes
WordPress in 30 minutesWordPress in 30 minutes
WordPress in 30 minutes
 
GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?GraphQL, l'avenir du REST ?
GraphQL, l'avenir du REST ?
 
Meteor WWNRW Intro
Meteor WWNRW IntroMeteor WWNRW Intro
Meteor WWNRW Intro
 
PhpUnit Best Practices
PhpUnit Best PracticesPhpUnit Best Practices
PhpUnit Best Practices
 
Microservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud NetflixMicroservices With Spring Boot and Spring Cloud Netflix
Microservices With Spring Boot and Spring Cloud Netflix
 
Learn Frontend Testing
Learn Frontend TestingLearn Frontend Testing
Learn Frontend Testing
 
Theme Development and Customization
Theme Development and CustomizationTheme Development and Customization
Theme Development and Customization
 

Kürzlich hochgeladen

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 

Kürzlich hochgeladen (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 

CSS Preprocessors: Cleaner Code & More Powerful Stylesheets

  • 1. 10 2102 HT81 REBOTCO , NOIT NEV NOC I NMULA EAS CSS PREPROCESSORS O T N OI T CU D O R TNI N A O T N OI T CU D O R TNI N A
  • 2. O R TNI K CIU Q O R TNI K CIU Q EM TUOBA EM TUOBA Milos Sutanovac Front-End Engineer Uhm… something with code & design, I guess? JavaScript, HTML5, CSS3 @ SAE Munich Bachelor of Arts, Web Development twitter.com/mixn
  • 3. ?TAHT SI YLTCAXE TAHW ?TAHT SI YLTCAXE TAHW ” R OSS E C O RP E RP “ ” R OSS E C O RP E RP “
  • 5. AI D EPI KI W AI D EPI KI W “ In computer science, a preprocessor is a program that processes its input data to produce output that is used as input to another program. [...] — Wikipedia ”
  • 6. ” R OSS E C O RP E RP SS C “ ” R OSS E C O RP E RP SS C “ Extension to CSS, which compiles to regular CSS Superset More functionalities Outputs regular, cross-browser code No limitations, since not regular CSS Makes CSS more flexible & fun to write (again)
  • 7. ROSSECOR PER P .SV SSC ROSSECOR PER P .SV SSC N OSI R AP M O C K CI U Q N OSI R AP M O C K CI U Q
  • 8. SS C SS C No expressions or math wdh 5*(0p +2;/ 50x Wsfltikn * it: 10x ) * 1p? ihu hnig / No logic Lack of variables Lack of abstraction @motul'yorpycs) ipr r(tpgah.s'; @motul'ics) ipr r(u.s'; / EtaHT rqet * * xr TP euss / Vendor Prefix Hell
  • 9. S R OSS E C O RP E RP S R OSS E C O RP E RP Cleaner, shorter syntax Variables Interpolation Nesting Expressions & Calculations Mixins, Imports, Functions, Statements, Includes, Inheritance, Loops, Logic …
  • 10. U SULYTS ,SSAS ,SSEL S N OI T C NI TSI D S N OI T C NI TSI D & S E CI O H C & S E CI O H C
  • 11. ”EGAUG NAL TEEHSELYTS CIMA NYD EHT“ ”EGAUG NAL TEEHSELYTS CIMA NYD EHT“ Alexis Sellier lesscss.org Originally in Ruby, deprecated & replaced by JavaScript .less Installation nmisalls p ntl es ls syels es tl.es Syntax example @oo:#0FE clr CFE; .igt{ wde bcgon:@oo; akrud clr }
  • 12. ”EDUTITTA HTIW ELYTS“ ”EDUTITTA HTIW ELYTS“ Hampton Catlin, Nathan Weizenbaum & Chris Eppstein sass-lang.com Written in Ruby .scss, .sass Installation gmisalss e ntl as m syecssyess v tl.s tl.cs ss syess syecs as tl.cs tl.s ss -wthsyess as -ac tl.as Syntax example $oo:#0FE clr CFE; .igt{ wde bcgon:$oo; akrud clr }
  • 13. ”SSC TSUBOR ,CIMA NYD ,EVISSER PXE“ ”SSC TSUBOR ,CIMA NYD ,EVISSER PXE“ TJ Holowaychuk learnboost.github.com/stylus Written in JavaScript .styl Installation nmisalsyu p ntl tls syu - syesy tls c tl.tl Syntax example clr=#0FE oo CFE .igt wde clrclr oo oo
  • 14. SSEL G NISU ,SUOIRUC UOY G NI KAM SSEL G NISU ,SUOIRUC UOY G NI KAM N WO DNU R E RU TA E F N WO DNU R E RU TA E F
  • 15. & S EL B AI R A V & S EL B AI R A V N OI T AL OP R E TNI N OI T AL OP R E TNI @rmrClr #ffb piayoo: ffd; @mPt:'.ig' igah ./m/; .igt{ wde bcgon:ul'{mPt}edrb.n' rpa-; akrud r(@igahhae_gpg) eetx clr @rmrClr oo: piayoo; }
  • 16. G NI TS E N G NI TS E N @otie 10; fnSz: 6% nv{ a fn-ie @otie otsz: fnSz; l { i fot lf; la: et a{ dsly iln-lc; ipa: niebok &hvr{ :oe clr htik oo: opn; } } } } Dangerous, can result in code bloat Preprocessing or not, embrace things like SMACSS & OOCSS CSS structure !== HTML structure Inception rule: don’t go more than four levels deep
  • 17. & S N OISS E RP X E & S N OISS E RP X E SN OI T ALU CL A C SN OI T ALU CL A C @o:5; fo % @a:@o *2 / 5 *2=1% br fo ; / % 0 @abz (br+@o)*5 / (0 +5)*5=7% fza: @a fo ; / 1% % 5 .igt{ wde wdh @abz-2;/ 7%-2 =5% it: fza 5 / 5 5 0 }
  • 18. SNIXI M SNIXI M .nmtd{ aiae -ektaiain ple.ses-n wbi-nmto: us 5 aei; -o-nmto:ple.ses-n mzaiain us 5 aei; -saiain ple.ses-n m-nmto: us 5 aei; --nmto:ple.ses-n oaiain us 5 aei; aiain ple.ses-n nmto: us 5 aei; } .nmtdwde { aiae_igt .nmtd aiae; } Can have parameters (with default values) .nmtd(tmnFnto:lna){ aiae @iigucin ier -ektaiain ple.s@iigucin wbi-nmto: us 5 tmnFnto; -o-nmto:ple.s@iigucin mzaiain us 5 tmnFnto; -saiain ple.s@iigucin m-nmto: us 5 tmnFnto; --nmto:ple.s@iigucin oaiain us 5 tmnFnto; aiain ple.s@iigucin nmto: us 5 tmnFnto; } .nmtdwde { aiae_igt .nmtd aiae; } .nte_nmtdwde { aohraiae_igt .nmtdes-n; aiae(aei) }
  • 19. S T R OP MI S T R OP MI / Isedo ti / nta f hs @motul'yorpycs) ipr r(tpgah.s'; / D ti / o hs @mot'yorpycs; ipr tpgah.s' No extra HTTP request Concatination behind the scenes
  • 20. SN OI T CNU F SN OI T CNU F lgtn@oo,1%; ihe(clr 0) / rtr aclrwihi 1%lgtrta @oo / eun oo hc s 0 ihe hn clr dre(clr 1%; akn@oo, 0) / rtr aclrwihi 1%dre ta @oo / eun oo hc s 0 akr hn clr strt(clr 1%; auae@oo, 0) / rtr aclr1%mr strtdta @oo / eun oo 0 oe auae hn clr dstrt(clr 1%; / rtr aclr1%ls strtdta @oo eauae@oo, 0) / eun oo 0 es auae hn clr fdi(clr 1%; aen@oo, 0) / rtr aclr1%ls tasaetta @oo / eun oo 0 es rnprn hn clr fdot@oo,1%; aeu(clr 0) / rtr aclr1%mr tasaetta @oo / eun oo 0 oe rnprn hn clr fd(clr 5%; ae@oo, 0) / rtr @oo wt 5%tasaec / eun clr ih 0 rnprny si(clr 1) pn@oo, 0; / rtr aclrwt a1 dge lre i heta @oo / eun oo ih 0 ere agr n u hn clr si(clr -0; pn@oo, 1) / rtr aclrwt a1 dge salrheta @oo / eun oo ih 0 ere mle u hn clr mx@oo1 @oo2; i(clr, clr) / rtr amxo @oo1ad@oo2 / eun i f clr n clr Sass & Stylus offer even more
  • 21. CI G O L & S T N E M E T A TS CI G O L & S T N E M E T A TS if, else, for, each, while Programming logic applied to CSS http://thesassway.com/intermediate/if-for-each-while
  • 22. S K C A B W A R D E M OS S K C A B W A R D E M OS TCEFRE P SI G NIHTO N ESUACEB TCEFRE P SI G NIHTO N ESUACEB Working on a team Editing the compiled .css file Increases room for errors Potential code bloat Choice? Not without a learning curve — but what is? Command Line Can be avoided: CodeKit , LiveReload , Compass.app , SCOUT Learn it — it’s the most powerful tool you have “ Learn to love the command line. It isn’t scary. You know how to use Photoshop which has 300 buttons — THAT’S scary. — Stephen Hay ”
  • 23. NOIT NETTA RUOY ROF NOIT NETTA RUOY ROF UO Y KNAH T UO Y KNAH T