SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
LESS & Sass
Overview
How to START with
Client-side way
Download less.js      Create style.less file
http://lesscss.org/   Instead of style.css
Link both files with the main HTML doc

          <link rel="stylesheet/less" href="styles.less" />




          <script src="less.js" ></script>
Server-side way
First possibility               Second possibility
Download NPM                    Download Ruby
                                http://www.ruby-lang.org/en/downloads
https://github.com/isaacs/npm


Or get Node.js                  For Windows users
http://nodejs.org/              http://rubyinstaller.org



 Now start the command prompt
If you chose NPM type:




 $ npm install -g less
If you chose Ruby type:




 $ gem install less
How to compile the Less code?
Client-side way
     It happens automatically when you hit (F5).
     You could also use some compilation tools.


Server-side way
     $ lessc style.less > style.css


   Less compiler          Output Css file

              Less file
LESS Compilers
Remember the client-side way, well this is pretty
much the same, but we have tools to help us.




 simpLess           CodeKit           LiveReload
How to START with
Just Server-side way   (there are dome unofficial client side ways)




   $ gem install sass
How to compile the Sass code?
Server-side way
       $ sass --watch style.scss : style.css


Sass compiler

      Watch for compilation


                        SASS code file   CSS code file
Less & Sass comparison
Variables
   just a value container
Sometimes we repeat the same value
over and over
#firstElement {
          background: #abcdef
}
#secondElement {                 background: #abcdef
          background : #abcdef

}
#thirdElement {
         color : #ff91aa;
}
...                               color : #ff91aa
#nthElement {
         color : #ff91aa;
}
LESS                           SASS
@bgColor : #abcdef;             $bgColor : #abcdef;
@justColor : #ff91aa;           $justColor : #ff91aa;

#firstElement{                  #firstElement{
        background: @bgColor;           background: $bgColor;
}                               }
Mixins
  variables on steroids
Sometimes we repeat a big chinks of code
with different values over and over
#justElement {
       -moz-bordee-radius: 10px;
       -webkit-border-radius: 10px;
       -o-border-radius: 10px;
       border-radius: 10px;
}
#anotherElement {
       /* if we want the same*/
}
LESS                                SASS
.roundBorder( @val : 10px ) {      @roundBorder( $val : 10x) {
    -moz-bordee-radius: @val;         -moz-bordee-radius: $val;
    -webkit-border-radius: @val;      -webkit-border-radius: $val;
    -o-border-radius: @val;           -o-border-radius: $val;
    border-radius: @val;              border-radius: $val;
}                                  }

#justElement{                      #justElement{
        .roundBorder( );                   @include roundBorder()
}                                  }
#anatherElement{                   #anotherElement{
        .roundBorder(17px);                @include roundBorder(17px)
}                                  }
Nested css code
   no more epic repetition code
If we have a lot of nested content is tedious to
have address the deepest elements
<div id=“main”>                   #main {
     <p>                                    width:500px
         <span>Span text</span>   }
         <a href=“#”>Link</a>     #main p {
     </p>                                 width: 150px;
</div>                            }
                                  #main p span {
                                          color: #abcdef;
                                  }
                                  #main p a {
                                          text-decoration: none;
                                  }
LESS and SaSS
#main{
         width: 500px;                      FIRST LEVEL NESTING (P ELEMENT)
         p{
                 width: 150px;
                                                          SECOND LEVEL NESTING
                                                          Span element
                 span {
                          color: #abcdef;
                 }
                 a{                                       SECOND LEVEL NESTING
                                                          anchor element
                          text-decoration: none;
                 }
         }
}
Functions & Operations
             a way to do the math
Operations

LESS example                     Sass example

// width variable                // width variable
@width: 500px;                   $width : 500px;

#divNewWidth {                   #divNewWidth {
      width: (@width + 10)             width: ($width + 10);
}                                }


Both Sass and Less supports math operators(+|-|*|/|%).
Functions
Both Sass and Less supports a variety of Math
and Color functions, that generated specific css
values

Sass functions:
http://sasslang.com/docs/yardoc/Sass/Script/Functions.html
Less functions:
http://lesscss.org/#-color-functions

Mais conteúdo relacionado

Mais procurados

Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
Dinu Suman
 
Stylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and CompassStylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and Compass
Dave Ross
 

Mais procurados (20)

Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introduction
 
Perl in the Internet of Things
Perl in the Internet of ThingsPerl in the Internet of Things
Perl in the Internet of Things
 
Sass presentation
Sass presentationSass presentation
Sass presentation
 
HTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsHTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventions
 
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)
 
PostCss
PostCssPostCss
PostCss
 
Css frameworks
Css frameworksCss frameworks
Css frameworks
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 
Ruby DSL
Ruby DSLRuby DSL
Ruby DSL
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
Modern Perl
Modern PerlModern Perl
Modern Perl
 
Server Scripting Language -PHP
Server Scripting Language -PHPServer Scripting Language -PHP
Server Scripting Language -PHP
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
API and DB design with Boolean
API and DB design with BooleanAPI and DB design with Boolean
API and DB design with Boolean
 
Building full-proof design tokens to support Kiwi.com's visual identity
Building full-proof design tokens to support Kiwi.com's visual identityBuilding full-proof design tokens to support Kiwi.com's visual identity
Building full-proof design tokens to support Kiwi.com's visual identity
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Php
PhpPhp
Php
 
Stylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and CompassStylesheets of the future with Sass and Compass
Stylesheets of the future with Sass and Compass
 
Php converted pdf
Php converted pdfPhp converted pdf
Php converted pdf
 
Ppt php
Ppt phpPpt php
Ppt php
 

Semelhante a Less & Sass

Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
edgincvg
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Kaelig Deloumeau-Prigent
 

Semelhante a Less & Sass (20)

Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
Using Sass - Building on CSS
Using Sass - Building on CSSUsing Sass - Building on CSS
Using Sass - Building on CSS
 
Sass - Making CSS fun again.
Sass - Making CSS fun again.Sass - Making CSS fun again.
Sass - Making CSS fun again.
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 
Work and play with SASS & Compass
Work and play with SASS & CompassWork and play with SASS & Compass
Work and play with SASS & Compass
 
FCIP SASS Talk
FCIP SASS TalkFCIP SASS Talk
FCIP SASS Talk
 
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
Brian Hoke: WordCamp Toronto 2014 Presentation "Sass & WordPress"
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
 
Modularization css with sass
Modularization css with sassModularization css with sass
Modularization css with sass
 
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
 
Pacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASSPacific Northwest Drupal Summit: Basic & SASS
Pacific Northwest Drupal Summit: Basic & SASS
 
Why less?
Why less?Why less?
Why less?
 
LESS CSS
LESS CSSLESS CSS
LESS CSS
 
Simplify your CSS with Stylus and Nib
Simplify your CSS with Stylus and NibSimplify your CSS with Stylus and Nib
Simplify your CSS with Stylus and Nib
 

Mais de Михаил Петров (11)

JS Event Model
JS Event ModelJS Event Model
JS Event Model
 
DOM API Java Script
DOM API Java ScriptDOM API Java Script
DOM API Java Script
 
Object - Oriented Java Script
Object - Oriented Java ScriptObject - Oriented Java Script
Object - Oriented Java Script
 
strings and objects in JavaScript
strings and  objects in JavaScriptstrings and  objects in JavaScript
strings and objects in JavaScript
 
Arrays and Functions in JavaScript
Arrays and Functions in JavaScriptArrays and Functions in JavaScript
Arrays and Functions in JavaScript
 
JavaScript intro
JavaScript introJavaScript intro
JavaScript intro
 
Emmet(zen coding)
Emmet(zen coding)Emmet(zen coding)
Emmet(zen coding)
 
Html 5 Semantics overview
Html 5 Semantics overviewHtml 5 Semantics overview
Html 5 Semantics overview
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Pseudo CSS Selectors
Pseudo CSS SelectorsPseudo CSS Selectors
Pseudo CSS Selectors
 
Науката през погледа на младите
Науката през погледа на младитеНауката през погледа на младите
Науката през погледа на младите
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 

Less & Sass

  • 3. Client-side way Download less.js Create style.less file http://lesscss.org/ Instead of style.css
  • 4. Link both files with the main HTML doc <link rel="stylesheet/less" href="styles.less" /> <script src="less.js" ></script>
  • 5. Server-side way First possibility Second possibility Download NPM Download Ruby http://www.ruby-lang.org/en/downloads https://github.com/isaacs/npm Or get Node.js For Windows users http://nodejs.org/ http://rubyinstaller.org Now start the command prompt
  • 6. If you chose NPM type: $ npm install -g less
  • 7. If you chose Ruby type: $ gem install less
  • 8. How to compile the Less code? Client-side way It happens automatically when you hit (F5). You could also use some compilation tools. Server-side way $ lessc style.less > style.css Less compiler Output Css file Less file
  • 9. LESS Compilers Remember the client-side way, well this is pretty much the same, but we have tools to help us. simpLess CodeKit LiveReload
  • 10. How to START with
  • 11. Just Server-side way (there are dome unofficial client side ways) $ gem install sass
  • 12. How to compile the Sass code? Server-side way $ sass --watch style.scss : style.css Sass compiler Watch for compilation SASS code file CSS code file
  • 13. Less & Sass comparison
  • 14. Variables just a value container
  • 15. Sometimes we repeat the same value over and over #firstElement { background: #abcdef } #secondElement { background: #abcdef background : #abcdef } #thirdElement { color : #ff91aa; } ... color : #ff91aa #nthElement { color : #ff91aa; }
  • 16. LESS SASS @bgColor : #abcdef; $bgColor : #abcdef; @justColor : #ff91aa; $justColor : #ff91aa; #firstElement{ #firstElement{ background: @bgColor; background: $bgColor; } }
  • 17. Mixins variables on steroids
  • 18. Sometimes we repeat a big chinks of code with different values over and over #justElement { -moz-bordee-radius: 10px; -webkit-border-radius: 10px; -o-border-radius: 10px; border-radius: 10px; } #anotherElement { /* if we want the same*/ }
  • 19. LESS SASS .roundBorder( @val : 10px ) { @roundBorder( $val : 10x) { -moz-bordee-radius: @val; -moz-bordee-radius: $val; -webkit-border-radius: @val; -webkit-border-radius: $val; -o-border-radius: @val; -o-border-radius: $val; border-radius: @val; border-radius: $val; } } #justElement{ #justElement{ .roundBorder( ); @include roundBorder() } } #anatherElement{ #anotherElement{ .roundBorder(17px); @include roundBorder(17px) } }
  • 20. Nested css code no more epic repetition code
  • 21. If we have a lot of nested content is tedious to have address the deepest elements <div id=“main”> #main { <p> width:500px <span>Span text</span> } <a href=“#”>Link</a> #main p { </p> width: 150px; </div> } #main p span { color: #abcdef; } #main p a { text-decoration: none; }
  • 22. LESS and SaSS #main{ width: 500px; FIRST LEVEL NESTING (P ELEMENT) p{ width: 150px; SECOND LEVEL NESTING Span element span { color: #abcdef; } a{ SECOND LEVEL NESTING anchor element text-decoration: none; } } }
  • 23. Functions & Operations a way to do the math
  • 24. Operations LESS example Sass example // width variable // width variable @width: 500px; $width : 500px; #divNewWidth { #divNewWidth { width: (@width + 10) width: ($width + 10); } } Both Sass and Less supports math operators(+|-|*|/|%).
  • 25. Functions Both Sass and Less supports a variety of Math and Color functions, that generated specific css values Sass functions: http://sasslang.com/docs/yardoc/Sass/Script/Functions.html Less functions: http://lesscss.org/#-color-functions