SlideShare una empresa de Scribd logo
1 de 24
The power to take advantage
of dynamic behavior
b
Agenda
• What is {Less}?
• Why {Less}?
• Implementation of {Less} in websites.
• Comparison between Less and Sass
• Overview of the syntax with examples.
b
What is {Less}?
• Dynamic style sheet language designed by Alexis Sellier from
Berlin - @cloudhead.
• Open source - Apache 2 License.
• Less was designed as a Nested metalanguage
- valid CSS is valid Less code with the same semantics.
• Less can run client-side (IE8+, WebKit, Firefox).
• Less can run server-side (Node.js).
• Less can be pre-compiled into CSS.
• First version of was written in Ruby but this was replaced by a
JavaScript version.
b
Why {Less}?
• Save time
• Reduce mistakes
• Reduce repetition
• It makes logical sense to break out CSS into multiple files
• More Readability
b
Implementation of {Less} in
websites.
• Let the website convert the Less code to CSS on the fly by
including the less.js file – available from http://www.lesscss.org
• Download less.js from www.lesscss.org
• Add your Less CSS code to a text file with a .less extension eg.
styles.less
• Include less.js with your styles:
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="less.js" type="text/javascript"></script>
b
Comparison between Less and Sass
• Sass is more mature and has slightly more features[compass ]
• They are pre-processed differently:
• Less uses JavaScript and can run client-side.
• Sass uses Ruby so runs server-side.
• Less can be slower to compile on the fly when running client-
side.
• Both can be pre-compiled into pure CSS before uploading
style sheets to sites – meaning no difference in performance.
• Syntax - https://gist.github.com/674726
• https://gist.github.com/wilmoore/820035
• http://www.hongkiat.com/blog/sass-vs-less/
•
http://www.quora.com/Which-is-better-Less-Compass-or-Sass
b
Less CSS compilers
Respectively all major editors can be used for writing
{Less}
• Free compiler for mac –
http://incident57.com/less
• Free compiler for mac, pc, Linux –
http://wearekiss.com/simpless
http://winless.org/online-less-compiler
WinLess
Crunch!
Mixture
Adobe Dream Weaver
Notepad++
Sublime Text 2
Kineticwing IDE
Coda
Geany
b
Syntax with examples.
-LESS has everything that CSS is missing. {Less} allows the
dynamic editability options for dynamic stylesheet with help of
these
• Variables
• Mixins
• Cascading + Nesting
• &combinator
• Operations
• Comments
• @import
• String interpolation
• Escaping
• Namespaces
• Scope
• Extend
• Loops
b
Variables
• Start with @ symbol
• Can storehexadecimalcolors, e.g. #333 or #fefefe
• Can store strings, e.g. “Webucator, Inc.”
• Can store sizes, e.g. 10px
LESS Syntax CSS Output
// Declare a numeric variable
@red: #ff0000;
// Declare a string variable
@path: "/sites/default/files/images";
// Apply these variables
.block {
color: @red;
background:url('@{path}/mypic.jpg');
}
.block {
color: #ff0000;
background: url('/sites/default/
files/images/mypic.jpg');
}
b
Mixins
• Include properties from one ruleset to another
• Reuse code
• Can accept parameters
• Can define default value for parameters
• @arguments is a special variable that contains the ordered
value stored in all parameters
LESS Syntax CSS Output
.border-radius(@radius: 2px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
@gray: #333;
header > nav {
border:1px solid @gray;
.border-radius;
}
aside > nav {
.border-radius(5px);
}
header > nav {
border:1px solid #333;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
aside > nav {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
b
Cascading + Nesting
• Nest rulesets in place of cascading
• Can be used in combination with traditional cascading
approach
• Mimics your DOM structure
• Outputs to cascading rulesets
LESS Syntax LESS Nesting
header {
color: white;
}
header .logo {
width:300px;
float:left;
}
header > #searchcontainer {
width:300px;
float:right;
}
header > #searchcontainer input {
width:250px;
margin-right:6px;
color:@darkGray;
}
header > #searchcontainer input:focus
{
color:@lightGray;
}
header {
color: white;
.logo {
width:300px;
float:left;
}
#searchcontainer {
width:300px;
float:right;
input {
width:250px;
margin-right:6px;
color:@darkGray;
&:focus {
color:@lightGray;
}
}
}
}
b
&combinator
• Nested selector is concatenated to the parent selector
• Useful for pseudo-classes
• &:hover
• &:focus
LESS Syntax CSS Output
@gray: #333;
img {
border:none;
&:focus {
border:1px solid @gray;
}
@.inline {
display:inline;
}
}
img {
border:none;
}
img:focus {
border:1px solid #333;
}
img.inline {
display:inline;
}
b
Operations
- which let you create CSS properties mathematically.
• Any number, color or variable can be operated upon
• Math functions
• Math operators ( +, -, *, /)
• Color functions
LESS Syntax CSS Output
@padding: 2px;
figure {
padding:@padding;
img {
padding:@padding * 2;
}
figcaption {
padding:@padding + 4px;
}
}
figure {
padding:2px;
}
figure img {
padding:4px;
}
figure figcaption {
padding: 6px;
}
b
Comments
Comments are pretty straight-forward in LESS. Multiline
comments are preserved and included in the CSS output when
you compile the LESS, and single line comments are not
preserved. Therefore, you should generally use single line
comments, unless you really need the comment to be included
in the generated CSS.
• /* These comments are preserved into your compiled CSS */
• // These comments are silent
b
@import
• @import will compile and copy result into single file
• All variables and mixins are available to main file or files
imported after declarations
• Order matters
• Can include/ignore .less extension
• Can import “classic” css using .css extension
• You can break out files logically, but avoid the (terrible)
@import() statement in traditional CSS
LESS @IMPORT Syntax
// import normalize for CSS resets
@import "normalize";
// same as @import “normalize.less”;
// import mixins
@import "mixins";
// base for mobile devices
@import "base";
//tables and small laptops
@media only screen and (min-width: 768px) {
@import "768up";
}
//desktop
@media only screen and (min-width: 1030px) {
@import "1030up";
}
b
String Interpolation
• Use @{name} construct
• For embedding variable values within declarations
@baseUrl: “http://www.webucator.com/”;
@imageUri: “images/”;
background-image: url(‘@{baseUrl}@{imageUri}bg.png’);
background-image: url(‘http://www.webucator.com/images/bg.png’);
b
Namespaces
- Groups of styles that can be called by references.
- Very useful if you want to create your own CSS libraries or
distribute CSS
LESS Syntax CSS Output
#my_framework{
p{
margin:12px 0;
}
a{
color:blue;
text-decoration:none;
}
.submit{
background:red;
color:white;
padding:5px 12px;
}
}
.submit_button{
#my_framework > .submit;
}
#my_framework p{
margin:12px 0;
}
#my_framework a{
color:blue;
text-decoration:none;
}
#my_framework .submit{
background:red;
color:white;
padding:5px 12px;
}
.submit_button{
background:red;
color:white;
padding:5px 12px;
}
b
Scope
- Scope in Less is very similar to that of programming
languages. Variables and mixins are first looked for locally, and
if they aren't found, the compiler will look in the parent scope,
and so on.
LESS Scope Syntax
@var: red;
#page {
@var: white;
#header {
color: @var; // white
}
}
#footer {
color: @var; // red
}
b
Extend
- Extend is a Less pseudo-class which merges the selector it is
put on with ones that match what it references.
LESS Syntax CSS Output
nav ul {
&:extend(.inline);
background: blue;
}
.inline {
color: red;
}
nav ul {
background: blue;
}
.inline,
nav ul {
color: red;
}
b
Loops
- Creating loops
LESS Syntax CSS Output
.loop(@counter) when (@counter > 0) {
.loop((@counter - 1)); // next
iteration
width: (10px * @counter); // code for
each iteration
}
div {
.loop(5); // launch the loop
}
div {
width: 10px;
width: 20px;
width: 30px;
width: 40px;
width: 50px;
}
LESS Syntax CSS Output
.generate-columns(4);
.generate-columns(@n, @i: 1) when
(@i =< @n) {
.column-@{i} {
width: (@i * 100% / @n);
}
.generate-columns(@n, (@i + 1));
}
.column-1 {
width: 25%;
}
.column-2 {
width: 50%;
}
.column-3 {
width: 75%;
}
.column-4 {
width: 100%;
}
b
My Perspective
• It's easy to install, you can use a JavaScript file for client side
compiling during development, and there are several ways to
compile the less files to CSS server side for production.
• Syntax very close to original CSS.
• Easy to Understand
In the end, it is still up to the end-user’s decision to pick the
preprocessor of their choice. Be it Sass or LESS, as long as they are
comfortable and more productive.
b
References
• http://lesscss.org/features/
•
http://css-tricks.com/snippets/javascript/lighten-darken-color/
•
https://stackoverflow.com/questions/21821947/calculate-differen
• https://github.com/less/less.js/archive/master.zip
• http://www.lesscss.org
• http://leafo.net/lessphp
• http://sass-lang.com
• https://github.com/cloudhead
• http://en.wikipedia.org/wiki/LESS_(stylesheet_language)
• http://coding.smashingmagazine.com/2011/09/09/an-
introduction-to-less-and-comparison-to-sass
b
Thank You 

Más contenido relacionado

La actualidad más candente

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.
 
Developer skills
Developer skillsDeveloper skills
Developer skillswebger
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compassChris Lee
 
Bliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionIrfan Maulana
 
Responsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen GridsResponsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen GridsSuzanne Dergacheva
 
Sass Beginner Guide
Sass Beginner GuideSass Beginner Guide
Sass Beginner GuideRizal Putra
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The CosmeticIrfan Maulana
 
SharePoint 2010 branding
SharePoint 2010 brandingSharePoint 2010 branding
SharePoint 2010 brandingPhil Wicklund
 
Css Preprocessors
Css PreprocessorsCss Preprocessors
Css PreprocessorsEd Moore
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_phpJeanho Chu
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPressJames Steinbach
 

La actualidad más candente (20)

Less
LessLess
Less
 
Sass presentation
Sass presentationSass presentation
Sass presentation
 
SASS - CSS with Superpower
SASS - CSS with SuperpowerSASS - CSS with Superpower
SASS - CSS with Superpower
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)
 
Introduction to sass
Introduction to sassIntroduction to sass
Introduction to sass
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
Developer skills
Developer skillsDeveloper skills
Developer skills
 
Dallas Drupal Days 2012 - Introduction to less sass-compass
Dallas Drupal Days 2012  - Introduction to less sass-compassDallas Drupal Days 2012  - Introduction to less sass-compass
Dallas Drupal Days 2012 - Introduction to less sass-compass
 
Beautifying senc
Beautifying sencBeautifying senc
Beautifying senc
 
Bliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS Introduction
 
Responsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen GridsResponsive Design in Drupal with Zen and Zen Grids
Responsive Design in Drupal with Zen and Zen Grids
 
Sass Beginner Guide
Sass Beginner GuideSass Beginner Guide
Sass Beginner Guide
 
SASS for WordPress Workshop
SASS for WordPress WorkshopSASS for WordPress Workshop
SASS for WordPress Workshop
 
The web context
The web contextThe web context
The web context
 
Journey To The Front End World - Part2 - The Cosmetic
Journey To The Front End World - Part2 - The  CosmeticJourney To The Front End World - Part2 - The  Cosmetic
Journey To The Front End World - Part2 - The Cosmetic
 
SharePoint 2010 branding
SharePoint 2010 brandingSharePoint 2010 branding
SharePoint 2010 branding
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
Css Preprocessors
Css PreprocessorsCss Preprocessors
Css Preprocessors
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
 

Similar a LESS CSS

Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introductionrushi7567
 
LESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionLESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionrushi7567
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.Eugene Nor
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
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)Folio3 Software
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob Davarnia
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFxStefan Bauer
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
What is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - XhtmlchopWhat is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - Xhtmlchopxhtmlchop
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentationMario Noble
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsSanjoy Kr. Paul
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Anam Hossain
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with SassSven Wolfermann
 
Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Stefan Bauer
 

Similar a LESS CSS (20)

UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introduction
 
LESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionLESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introduction
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
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)
 
Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
What is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - XhtmlchopWhat is LessCSS and its Detailed Explation - Xhtmlchop
What is LessCSS and its Detailed Explation - Xhtmlchop
 
PostCss
PostCssPostCss
PostCss
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and Cons
 
CSS3
CSS3CSS3
CSS3
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
Fasten RWD Development with Sass
Fasten RWD Development with SassFasten RWD Development with Sass
Fasten RWD Development with Sass
 
Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan
 

Último

Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptrcbcrtm
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfkalichargn70th171
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 

Último (20)

Odoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting ServiceOdoo Development Company in India | Devintelle Consulting Service
Odoo Development Company in India | Devintelle Consulting Service
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
cpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.pptcpct NetworkING BASICS AND NETWORK TOOL.ppt
cpct NetworkING BASICS AND NETWORK TOOL.ppt
 
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdfExploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
Exploring Selenium_Appium Frameworks for Seamless Integration with HeadSpin.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 

LESS CSS

  • 1. The power to take advantage of dynamic behavior
  • 2. b Agenda • What is {Less}? • Why {Less}? • Implementation of {Less} in websites. • Comparison between Less and Sass • Overview of the syntax with examples.
  • 3. b What is {Less}? • Dynamic style sheet language designed by Alexis Sellier from Berlin - @cloudhead. • Open source - Apache 2 License. • Less was designed as a Nested metalanguage - valid CSS is valid Less code with the same semantics. • Less can run client-side (IE8+, WebKit, Firefox). • Less can run server-side (Node.js). • Less can be pre-compiled into CSS. • First version of was written in Ruby but this was replaced by a JavaScript version.
  • 4. b Why {Less}? • Save time • Reduce mistakes • Reduce repetition • It makes logical sense to break out CSS into multiple files • More Readability
  • 5. b Implementation of {Less} in websites. • Let the website convert the Less code to CSS on the fly by including the less.js file – available from http://www.lesscss.org • Download less.js from www.lesscss.org • Add your Less CSS code to a text file with a .less extension eg. styles.less • Include less.js with your styles: <link rel="stylesheet/less" type="text/css" href="styles.less"> <script src="less.js" type="text/javascript"></script>
  • 6. b Comparison between Less and Sass • Sass is more mature and has slightly more features[compass ] • They are pre-processed differently: • Less uses JavaScript and can run client-side. • Sass uses Ruby so runs server-side. • Less can be slower to compile on the fly when running client- side. • Both can be pre-compiled into pure CSS before uploading style sheets to sites – meaning no difference in performance. • Syntax - https://gist.github.com/674726 • https://gist.github.com/wilmoore/820035 • http://www.hongkiat.com/blog/sass-vs-less/ • http://www.quora.com/Which-is-better-Less-Compass-or-Sass
  • 7. b Less CSS compilers Respectively all major editors can be used for writing {Less} • Free compiler for mac – http://incident57.com/less • Free compiler for mac, pc, Linux – http://wearekiss.com/simpless http://winless.org/online-less-compiler WinLess Crunch! Mixture Adobe Dream Weaver Notepad++ Sublime Text 2 Kineticwing IDE Coda Geany
  • 8. b Syntax with examples. -LESS has everything that CSS is missing. {Less} allows the dynamic editability options for dynamic stylesheet with help of these • Variables • Mixins • Cascading + Nesting • &combinator • Operations • Comments • @import • String interpolation • Escaping • Namespaces • Scope • Extend • Loops
  • 9. b Variables • Start with @ symbol • Can storehexadecimalcolors, e.g. #333 or #fefefe • Can store strings, e.g. “Webucator, Inc.” • Can store sizes, e.g. 10px LESS Syntax CSS Output // Declare a numeric variable @red: #ff0000; // Declare a string variable @path: "/sites/default/files/images"; // Apply these variables .block { color: @red; background:url('@{path}/mypic.jpg'); } .block { color: #ff0000; background: url('/sites/default/ files/images/mypic.jpg'); }
  • 10. b Mixins • Include properties from one ruleset to another • Reuse code • Can accept parameters • Can define default value for parameters • @arguments is a special variable that contains the ordered value stored in all parameters LESS Syntax CSS Output .border-radius(@radius: 2px) { -webkit-border-radius: @radius; -moz-border-radius: @radius; border-radius: @radius; } @gray: #333; header > nav { border:1px solid @gray; .border-radius; } aside > nav { .border-radius(5px); } header > nav { border:1px solid #333; -webkit-border-radius: 2px; -moz-border-radius: 2px; border-radius: 2px; } aside > nav { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; }
  • 11. b Cascading + Nesting • Nest rulesets in place of cascading • Can be used in combination with traditional cascading approach • Mimics your DOM structure • Outputs to cascading rulesets LESS Syntax LESS Nesting header { color: white; } header .logo { width:300px; float:left; } header > #searchcontainer { width:300px; float:right; } header > #searchcontainer input { width:250px; margin-right:6px; color:@darkGray; } header > #searchcontainer input:focus { color:@lightGray; } header { color: white; .logo { width:300px; float:left; } #searchcontainer { width:300px; float:right; input { width:250px; margin-right:6px; color:@darkGray; &:focus { color:@lightGray; } } } }
  • 12. b &combinator • Nested selector is concatenated to the parent selector • Useful for pseudo-classes • &:hover • &:focus LESS Syntax CSS Output @gray: #333; img { border:none; &:focus { border:1px solid @gray; } @.inline { display:inline; } } img { border:none; } img:focus { border:1px solid #333; } img.inline { display:inline; }
  • 13. b Operations - which let you create CSS properties mathematically. • Any number, color or variable can be operated upon • Math functions • Math operators ( +, -, *, /) • Color functions LESS Syntax CSS Output @padding: 2px; figure { padding:@padding; img { padding:@padding * 2; } figcaption { padding:@padding + 4px; } } figure { padding:2px; } figure img { padding:4px; } figure figcaption { padding: 6px; }
  • 14. b Comments Comments are pretty straight-forward in LESS. Multiline comments are preserved and included in the CSS output when you compile the LESS, and single line comments are not preserved. Therefore, you should generally use single line comments, unless you really need the comment to be included in the generated CSS. • /* These comments are preserved into your compiled CSS */ • // These comments are silent
  • 15. b @import • @import will compile and copy result into single file • All variables and mixins are available to main file or files imported after declarations • Order matters • Can include/ignore .less extension • Can import “classic” css using .css extension • You can break out files logically, but avoid the (terrible) @import() statement in traditional CSS LESS @IMPORT Syntax // import normalize for CSS resets @import "normalize"; // same as @import “normalize.less”; // import mixins @import "mixins"; // base for mobile devices @import "base"; //tables and small laptops @media only screen and (min-width: 768px) { @import "768up"; } //desktop @media only screen and (min-width: 1030px) { @import "1030up"; }
  • 16. b String Interpolation • Use @{name} construct • For embedding variable values within declarations @baseUrl: “http://www.webucator.com/”; @imageUri: “images/”; background-image: url(‘@{baseUrl}@{imageUri}bg.png’); background-image: url(‘http://www.webucator.com/images/bg.png’);
  • 17. b Namespaces - Groups of styles that can be called by references. - Very useful if you want to create your own CSS libraries or distribute CSS LESS Syntax CSS Output #my_framework{ p{ margin:12px 0; } a{ color:blue; text-decoration:none; } .submit{ background:red; color:white; padding:5px 12px; } } .submit_button{ #my_framework > .submit; } #my_framework p{ margin:12px 0; } #my_framework a{ color:blue; text-decoration:none; } #my_framework .submit{ background:red; color:white; padding:5px 12px; } .submit_button{ background:red; color:white; padding:5px 12px; }
  • 18. b Scope - Scope in Less is very similar to that of programming languages. Variables and mixins are first looked for locally, and if they aren't found, the compiler will look in the parent scope, and so on. LESS Scope Syntax @var: red; #page { @var: white; #header { color: @var; // white } } #footer { color: @var; // red }
  • 19. b Extend - Extend is a Less pseudo-class which merges the selector it is put on with ones that match what it references. LESS Syntax CSS Output nav ul { &:extend(.inline); background: blue; } .inline { color: red; } nav ul { background: blue; } .inline, nav ul { color: red; }
  • 20. b Loops - Creating loops LESS Syntax CSS Output .loop(@counter) when (@counter > 0) { .loop((@counter - 1)); // next iteration width: (10px * @counter); // code for each iteration } div { .loop(5); // launch the loop } div { width: 10px; width: 20px; width: 30px; width: 40px; width: 50px; } LESS Syntax CSS Output .generate-columns(4); .generate-columns(@n, @i: 1) when (@i =< @n) { .column-@{i} { width: (@i * 100% / @n); } .generate-columns(@n, (@i + 1)); } .column-1 { width: 25%; } .column-2 { width: 50%; } .column-3 { width: 75%; } .column-4 { width: 100%; }
  • 21. b My Perspective • It's easy to install, you can use a JavaScript file for client side compiling during development, and there are several ways to compile the less files to CSS server side for production. • Syntax very close to original CSS. • Easy to Understand In the end, it is still up to the end-user’s decision to pick the preprocessor of their choice. Be it Sass or LESS, as long as they are comfortable and more productive.
  • 22. b References • http://lesscss.org/features/ • http://css-tricks.com/snippets/javascript/lighten-darken-color/ • https://stackoverflow.com/questions/21821947/calculate-differen • https://github.com/less/less.js/archive/master.zip • http://www.lesscss.org • http://leafo.net/lessphp • http://sass-lang.com • https://github.com/cloudhead • http://en.wikipedia.org/wiki/LESS_(stylesheet_language) • http://coding.smashingmagazine.com/2011/09/09/an- introduction-to-less-and-comparison-to-sass
  • 23. b