SlideShare ist ein Scribd-Unternehmen logo
1 von 57
Downloaden Sie, um offline zu lesen
LESS, The CSS
  Preprocessor

        Andrea Tarr
  MetaScale /Sears Holdings
Joomla Day New England 2013
What is LESS
Using LESS
LESS in Joomla




April 13, 2013   JDNE: LESS, The CSS Preprocessor   2
Dynamic CSS
Easy Customization
Reuse
Power of Variables




April 13, 2013   JDNE: LESS, The CSS Preprocessor   3
Dynamic CSS
Super set of CSS



.LESS
April 13, 2013   JDNE: LESS, The CSS Preprocessor   4
Preprocessing
Client Side
http://lesscss.org




April 13, 2013   JDNE: LESS, The CSS Preprocessor   5
<link rel="stylesheet/
less" type="text/css"
href="styles.less" />
<script src="less.js"
type="text/javascript"></
script>


April 13, 2013   JDNE: LESS, The CSS Preprocessor   6
Preprocessing
Server Side
http://leafo.net/lessphp
http://nodejs.org




April 13, 2013   JDNE: LESS, The CSS Preprocessor   7
1.  Install node.js
http://nodejs.org
2. Install LESS
sudo npm install -g less
3. Process CSS files
lessc ../less/template.less
> template.css

April 13, 2013   JDNE: LESS, The CSS Preprocessor   8
Why LESS not SASS?
Faster
JavaScript
CSS Syntax




April 13, 2013   JDNE: LESS, The CSS Preprocessor   9
@
Variables
Define once,
use often




April 13, 2013   JDNE: LESS, The CSS Preprocessor   10
@text-color: #2c2c2c;
p{
  color: @text-color;
}




April 13, 2013   JDNE: LESS, The CSS Preprocessor   11
h2 {
  color: @text-color;
  border: 1px solid
@text-color;
}



April 13, 2013   JDNE: LESS, The CSS Preprocessor   12
Mixins
Shorthand classes




April 13, 2013
                                    .
                 JDNE: LESS, The CSS Preprocessor   13
.rounded {
  -webkit-border-radius:
5px;
  -moz-border-radius: 5px;
  -ms-border-radius: 5px;
  -o-border-radius: 5px;
  border-radius: 5px;
}

April 13, 2013   JDNE: LESS, The CSS Preprocessor   14
.sideboxa {
  .rounded;
}
.sideboxb {
  padding: 5px;
  .rounded;
}

April 13, 2013   JDNE: LESS, The CSS Preprocessor   15
()
Mixins
Parameters




April 13, 2013   JDNE: LESS, The CSS Preprocessor   16
.rounded (@radius: 5px) {
  -webkit-border-radius:
@radius;
  -moz-border-radius: @radius;
  -ms-border-radius: @radius;
  -o-border-radius: @radius;
  border-radius: @radius;
}

April 13, 2013   JDNE: LESS, The CSS Preprocessor   17
.sideboxa {
  .rounded;
}
.sideboxb {
  padding: 5px;
  .rounded(3px);
}

April 13, 2013   JDNE: LESS, The CSS Preprocessor   18
Operations                                          +
Math!
                                                    -
                                                    *
                                                    /
                                                    ()
April 13, 2013   JDNE: LESS, The CSS Preprocessor        19
@base-margin: 15px;
@base: 5%;
@filler: (@base * 2);
.box1 {
  margin-bottom: (@base-
margin + 20px);
  height: (100% / 2 + @filler);
}

April 13, 2013   JDNE: LESS, The CSS Preprocessor   20
@link-color: #3f43ca;
a{
  color: @link-color;
}
a:hover {
  color: (@link-color +
#222);
}
April 13, 2013   JDNE: LESS, The CSS Preprocessor   21
()
Functions
Built-in




April 13, 2013   JDNE: LESS, The CSS Preprocessor   22
@link-color: #3f43ca;
a{
  color: @link-color;
}
a:hover {
  color: lighten(@link-
color, 10%;
}
April 13, 2013   JDNE: LESS, The CSS Preprocessor   23
lighten(@color, 10%);
darken(@color, 10%);

saturate(@color, 10%);
desaturate(@color, 10%);

fadein(@color, 10%);
spin(@color, 10);
April 13, 2013   JDNE: LESS, The CSS Preprocessor   24
/*
Comments
CSS Style
Included


                                      */
April 13, 2013   JDNE: LESS, The CSS Preprocessor   25
/* Header styles
for blog pages */




April 13, 2013   JDNE: LESS, The CSS Preprocessor   26
//
Comments
Single line
Not included




April 13, 2013   JDNE: LESS, The CSS Preprocessor   27
// Override from template




April 13, 2013   JDNE: LESS, The CSS Preprocessor   28
@
@import
CSS files
LESS files




April 13, 2013   JDNE: LESS, The CSS Preprocessor   29
@import          "variables.less";
@import          "mixins.less";
@import          "layout.less";
@import          "grid.less";

Compiles to single file


April 13, 2013   JDNE: LESS, The CSS Preprocessor   30
Nesting
                                                {
                                                    .{}
                                                    &{ }
                                                }
April 13, 2013   JDNE: LESS, The CSS Preprocessor          31
#header { color: #2c2c2c; }
#header .navigation {
 font-size: 12px; }
#header .logo {
 width: 300px; }
#header .logo:hover {
 text-decoration: underline; }


April 13, 2013   JDNE: LESS, The CSS Preprocessor   32
#header      {           color: #2c2c2c;
 .navigation {           font-size: 12px; }
 .logo       {           width: 300px;
   &:hover   {           text-decoration:
                           underline; }
    }
}


April 13, 2013   JDNE: LESS, The CSS Preprocessor   33
Debug Issues
Firebug gives CSS line
Search LESS files for
multiple selectors
Doesn't work when
nested


April 13, 2013   JDNE: LESS, The CSS Preprocessor   34
LESS in Joomla




April 13, 2013   JDNE: LESS, The CSS Preprocessor   35
You don't
need LESS
for Joomla
templates
April 13, 2013   JDNE: LESS, The CSS Preprocessor   36
Joomla Bootstrap files
are already compiled
Some Bootstrap
template vendors don't
distribute LESS files



April 13, 2013   JDNE: LESS, The CSS Preprocessor   37
You don't need LESS in
Joomla

... but it's very helpful!




April 13, 2013   JDNE: LESS, The CSS Preprocessor   38
Joomla JUI files
media
 jui
   css
   fonts
   img
   js
   less
April 13, 2013   JDNE: LESS, The CSS Preprocessor   39
media/jui/less
accordion.less
alerts.less
bootstrap-extended.less
bootstrap-rtl.less
bootstrap.less
breadcrumbs.less
button-groups.less
buttons.less
April 13, 2013   JDNE: LESS, The CSS Preprocessor   40
carousel.less
close.less
code.less
component-
animations.less
dropdowns.less
forms.less
grid.less
hero-unit.less
April 13, 2013   JDNE: LESS, The CSS Preprocessor   41
icomoon.less
labels-badges.less
layouts.less
mixins.less
modals.less
navbar.less
navs.less
pager.less
April 13, 2013   JDNE: LESS, The CSS Preprocessor   42
pagination.less
popovers.less
progress-bars.less
reset.less
responsive-1200px-
min.less
responsive-767px-
max.less
April 13, 2013   JDNE: LESS, The CSS Preprocessor   43
responsive-768px-979p
x.less
responsive-navbar.less
responsive-utilities.less
responsive.less
scaffolding.less
sprites.less
tables.less
thumbnails.less
April 13, 2013   JDNE: LESS, The CSS Preprocessor   44
tooltip.less
type.less
utilities.less
variables.less
wells.less



April 13, 2013   JDNE: LESS, The CSS Preprocessor   45
JUI Extensions
bootstrap-extended.less




April 13, 2013   JDNE: LESS, The CSS Preprocessor   46
Bootstrap.less
contains @imports of
other less files.

Replace bootstrap.less
with template.less in
your template.

April 13, 2013   JDNE: LESS, The CSS Preprocessor   47
mytemplate
 css
   template.css
 html
 images
 less
   template.less
   variables.less
 index.php
April 13, 2013   JDNE: LESS, The CSS Preprocessor   48
variables.less
Sets up variables for
your template
Copy file from media/jui/
less and change it in your
template


April 13, 2013   JDNE: LESS, The CSS Preprocessor   49
variables.less
@bodyBackground: #ffffff;
@textColor: #2c2c2c;
@linkColor: #08c08d;
@linkColorHover:
darken(@linkColor, 15%);
@sansFontFamily: "Helvetica
Neue", Helvetica, Arial, sans-
serif;
April 13, 2013   JDNE: LESS, The CSS Preprocessor   50
template.less
@import less files from
media/jui/less
@import any less files in
your template
Add styles for your
template using less

April 13, 2013   JDNE: LESS, The CSS Preprocessor   51
Remember,
straight CSS
is valid LESS.
Add in LESS where it is
helpful. Ignore it where
it would be confusing.
April 13, 2013   JDNE: LESS, The CSS Preprocessor   52
template.less
@import "../../../media/jui/
less/reset.less";
@import "variables.less";
@import "../../../media/jui/
less/mixins.less";
@import "../../../media/jui/
less/scaffolding.less";
etc...
April 13, 2013   JDNE: LESS, The CSS Preprocessor   53
template.less (con't)
@import "../../../media/jui/
less/bootstrap-
extended.less";
Has to be after the other
Bootstrap @imports to
override when necessary

April 13, 2013   JDNE: LESS, The CSS Preprocessor   54
template.less (con't)
After the imports, add
your styles
.img_caption .right {
  float: right;
  margin-left: 1em;
}

April 13, 2013   JDNE: LESS, The CSS Preprocessor   55
Compile template.less
lessc ../less/template.less
> template.css
Call the template.css file
in your index.php file as
usual.


April 13, 2013   JDNE: LESS, The CSS Preprocessor   56
Questions?


April 13, 2013   JDNE: LESS, The CSS Preprocessor   57

Weitere ähnliche Inhalte

Was ist angesagt?

Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 Minutes
Patrick Crowley
 
LESS is More
LESS is MoreLESS is More
LESS is More
jsmith92
 
Drawing the Line with Browser Compatibility
Drawing the Line with Browser CompatibilityDrawing the Line with Browser Compatibility
Drawing the Line with Browser Compatibility
jsmith92
 

Was ist angesagt? (20)

How to use CSS3 in WordPress
How to use CSS3 in WordPressHow to use CSS3 in WordPress
How to use CSS3 in WordPress
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Sass
SassSass
Sass
 
Haml And Sass In 15 Minutes
Haml And Sass In 15 MinutesHaml And Sass In 15 Minutes
Haml And Sass In 15 Minutes
 
LESS CSS Pre-processor
LESS CSS Pre-processorLESS CSS Pre-processor
LESS CSS Pre-processor
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
 
Css frameworks
Css frameworksCss frameworks
Css frameworks
 
From PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to lifeFrom PSD to WordPress Theme: Bringing designs to life
From PSD to WordPress Theme: Bringing designs to life
 
BDUG Responsive Web Theming - 7/23/12
BDUG Responsive Web Theming - 7/23/12BDUG Responsive Web Theming - 7/23/12
BDUG Responsive Web Theming - 7/23/12
 
HTML CSS & Javascript
HTML CSS & JavascriptHTML CSS & Javascript
HTML CSS & Javascript
 
Modern Front-End Development
Modern Front-End DevelopmentModern Front-End Development
Modern Front-End Development
 
Compile your Style
Compile your StyleCompile your Style
Compile your Style
 
LESS is More
LESS is MoreLESS is More
LESS is More
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
 
Responsive Websites
Responsive WebsitesResponsive Websites
Responsive Websites
 
Intro to Sass for WordPress Developers
Intro to Sass for WordPress DevelopersIntro to Sass for WordPress Developers
Intro to Sass for WordPress Developers
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Drawing the Line with Browser Compatibility
Drawing the Line with Browser CompatibilityDrawing the Line with Browser Compatibility
Drawing the Line with Browser Compatibility
 
How to use CSS3 in WordPress - Sacramento
How to use CSS3 in WordPress - SacramentoHow to use CSS3 in WordPress - Sacramento
How to use CSS3 in WordPress - Sacramento
 
CSS in React
CSS in ReactCSS in React
CSS in React
 

Ähnlich wie LESS, the CSS Preprocessor

SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
Itai Koren
 
Performance & Responsive Web Design
Performance & Responsive Web DesignPerformance & Responsive Web Design
Performance & Responsive Web Design
Zach Leatherman
 
Elegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs SassElegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs Sass
Mediacurrent
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
Jon Dean
 

Ähnlich wie LESS, the CSS Preprocessor (20)

Bootstrap & Joomla UI
Bootstrap & Joomla UIBootstrap & Joomla UI
Bootstrap & Joomla UI
 
Optimización JavaScript y CSS
Optimización JavaScript y CSSOptimización JavaScript y CSS
Optimización JavaScript y CSS
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nl
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
Less, bootstrap and more
Less, bootstrap and moreLess, bootstrap and more
Less, bootstrap and more
 
Create a new project in ROR
Create a new project in RORCreate a new project in ROR
Create a new project in ROR
 
Performance & Responsive Web Design
Performance & Responsive Web DesignPerformance & Responsive Web Design
Performance & Responsive Web Design
 
Styling your projects! leveraging css and r sass in r projects
Styling your projects! leveraging css and r sass in r projectsStyling your projects! leveraging css and r sass in r projects
Styling your projects! leveraging css and r sass in r projects
 
Drupal 7: Theming with the SASS Framework
Drupal 7: Theming with the SASS FrameworkDrupal 7: Theming with the SASS Framework
Drupal 7: Theming with the SASS Framework
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style GuidesAdvanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
Advanced Front End Architecture in D8: Sass, Gulp, & Living Style Guides
 
Measuring Web Performance
Measuring Web Performance Measuring Web Performance
Measuring Web Performance
 
Lasso and Couchdb : the happy couple
Lasso and Couchdb : the happy coupleLasso and Couchdb : the happy couple
Lasso and Couchdb : the happy couple
 
.NET Development for SQL Server Developer - Sql Saturday #264 Ancona
.NET Development for SQL Server Developer - Sql Saturday #264 Ancona.NET Development for SQL Server Developer - Sql Saturday #264 Ancona
.NET Development for SQL Server Developer - Sql Saturday #264 Ancona
 
Elegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs SassElegant CSS Design In Drupal: LESS vs Sass
Elegant CSS Design In Drupal: LESS vs Sass
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
Scott Jehl - Delivering Responsibly - beyond tellerrand Düsseldorf 2015
 
Backbone
BackboneBackbone
Backbone
 
Kharkivpy#3: Javascript and Python backend
Kharkivpy#3: Javascript and Python backendKharkivpy#3: Javascript and Python backend
Kharkivpy#3: Javascript and Python backend
 

Mehr von Andrea Tarr

The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013
Andrea Tarr
 

Mehr von Andrea Tarr (6)

The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013
 
Bootstrap for Extension Developers JWC 2012
Bootstrap for Extension Developers  JWC 2012Bootstrap for Extension Developers  JWC 2012
Bootstrap for Extension Developers JWC 2012
 
Bootstrap Introduction
Bootstrap IntroductionBootstrap Introduction
Bootstrap Introduction
 
PHP for HTML Gurus - J and Beyond 2012
PHP for HTML Gurus - J and Beyond 2012PHP for HTML Gurus - J and Beyond 2012
PHP for HTML Gurus - J and Beyond 2012
 
Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012
 
Choosing Great Joomla Extensions
Choosing Great Joomla ExtensionsChoosing Great Joomla Extensions
Choosing Great Joomla Extensions
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 

LESS, the CSS Preprocessor