SlideShare a Scribd company logo
{LESS}
CSS Pre-processor
● Introduction
● Variables
● Operations
● Functions
● Extend
● Mixins
● Loops
● Merge
● Compile LESS to CSS
● TODO
Outline
● What is LESS?
○ Less is a CSS pre-processor, meaning that it
extends the CSS language, adding features that
allow variables, mixins, functions and many other
techniques that allow you to make CSS that is
more maintainable, themeable and extendible.
● Usage Development Mode
Introduction
LESS
<link rel="stylesheet/less" type="text/css" href="styles.less" />
Library
<script src="less.js" type="text/javascript"></script>
● Color
Variables (1/7)
// Variables
@link-color: #0000ff;
@btn-color: white;
// Usage
a {
color: @link-color;
}
button {
color: @btn-color;
background: @link-color;
}
LESS
// Outputs
a {
color: #0000ff;
}
button {
color: #ffffff;
background: #0000ff;
}
CSS (outputs)
● URLs
Variables (2/7)
// Variables
@images: "../img";
// Usage
button {
background: url("@{images}/button_blue.png");
}
LESS
// Outputs
button {
background: url("../img/button_blue.png");
}
CSS (outputs)
● Selectors
Variables (3/7)
// Variables
@mySelector: banner;
// Usage
.@{mySelector} {
font-weight: bold;
line-height: 40px;
margin: 0 auto;
}
LESS
// Outputs
.banner {
font-weight: bold;
line-height: 40px;
margin: 0 auto;
}
CSS (outputs)
● Properties
Variables (4/7)
// Variable
@property: color;
// Usage
.widget {
@{property}: #0ee;
background-@{property}: #999;
}
LESS
// Outputs
.widget {
color: #0ee;
background-color: #999;
}
CSS (outputs)
● Variable Names
Variables (5/7)
// Variable
@fnord: "I am fnord.";
@var: "fnord";
// Usage
.text {
content: @@var;
}
LESS
// Outputs
.text {
content: "I am fnord.";
}
CSS (outputs)
● Lazy Loading
○ Variables are lazy loaded and do not have to be
declared before being used.
Variables (6/7)
.lazy-eval {
width: @var;
}
@var: @a;
@a: 9%;
LESS
.lazy-eval-scope {
width: 9%;
}
CSS (outputs)
● @import
○ Import styles from other style sheets
Variables (7/7)
@import "foo"; // foo.less is imported
@import "foo.less"; // foo.less is imported
@import "foo.php"; // foo.php imported as a less file
@import "foo.css"; // statement left in place, as-is
Operations
@base: 5%; // Outputs
@filler: @base * 2; // 10%
@other: @base + @filler; // 15%
@base-color: #222; //
@padding: 5px; //
color: #888 / 4; // #222222
background-color: @base-color + #111; // #333333
height: 100% / 2 + @filler; // 60%
padding: @padding + 5; // 10px
// Question???
margin: @base + @padding; // what is it?
● http://lesscss.org/functions/
Functions
@base: #0000ff;
@width: 0.5;
.class {
width: percentage(@width); // 50%
color: greyscale(@base, 5%); // #838383
background-color: lighten(@base, 25%); // #8080ff
}
// Output
.class {
width: 50%;
color: #838383;
background-color: #8080ff;
}
● Example 1
Extend (1/2)
nav ul {
&:extend(.inline);
background: blue;
}
.inline {
color: red;
}
LESS
nav ul {
background: blue;
}
.inline, nav ul {
color: red;
}
CSS (outputs)
● Example 2
Extend (2/2)
nav ul:extend(.inline) {
background: blue;
}
.inline {
color: red;
}
LESS
nav ul {
background: blue;
}
.inline, nav ul {
color: red;
}
CSS (outputs)
● Mixin
● Parametric Mixins
● Mixins as Functions
● Mixin Guards
Mixin Outline
● "mix-in" properties from existing styles
Mixins (1/3)
.a {
color: red;
}
#b {
background: blue;
}
.mixin-class {
.a();
}
.mixin-id {
#b();
}
LESS
.a {
color: red;
}
#b {
background: blue;
}
.mixin-class {
color: red;
}
.mixin-id {
background: blue;
}
CSS (outputs)
● Not outputting the mixin
Mixins (2/3)
.my-mixin {
color: black;
}
.my-other-mixin() {
background: white;
}
.class {
.my-mixin;
.my-other-mixin;
}
.my-mixin {
color: black;
}
.class {
color: black;
background: white;
}
CSS (outputs)LESS
● Selectors in mixins
Mixins (3/3)
.my-hover-mixin() {
&:hover {
border: 1px solid red;
}
color: white;
}
button {
.my-hover-mixin();
background: blue;
}
button {
color: white;
background: blue;
}
button:hover {
border: 1px solid red;
}
CSS (outputs)LESS
● How to pass arguments to mixins
Parametric Mixins (1/3)
.border-radius(@radius) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
.button {
.border-radius(6px);
}
LESS
CSS (outputs)
.button {
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
CSS (outputs)
● How to set default parameters to mixins
Parametric Mixins (2/3)
.border-radius(@radius: 5px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
border-radius: @radius;
}
.button {
.border-radius();
}
LESS
CSS (outputs)
.button {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
CSS (outputs)
● Mixins with Multiple Parameters
Parametric Mixins (3/3)
.mixin(@color; @padding) {
color: @color;
padding: @padding;
}
.some .selector div {
.mixin(blue, 2px);
}
LESS
CSS (outputs)
.some .selector div {
color: blue;
padding: 2px;
}
CSS (outputs)
● Return variables
Mixins as Functions (1/3)
.mixin() {
@width: 100%;
@height: 200px;
}
.caller {
.mixin();
width: @width;
height: @height;
}
.caller {
width: 100%;
height: 200px;
}
CSS (outputs)LESS
● Return mixin defined in mixin
Mixins as Functions (2/3)
.unlock(@value) {
.doSomething() {
padding: @value;
}
}
#namespace {
.unlock(5px);
.doSomething();
}
#namespace {
padding: 5px;
}
CSS (outputs)LESS
● Overridden global variables
Mixins as Functions (3/3)
@size: 10px;
.mixin() {
@size: 5px;
@inMixin: 20px;
}
.class {
margin: @size @inMixin;
.mixin();
}
.other-class {
margin: @size;
}
.class {
margin: 5px 20px;
}
.other-class {
margin: 10px;
}
CSS (outputs)LESS
● Conditional mixins
Mixin Guards (1/3)
.mixin(@a) when (lightness
(@a) >= 50%) {
background-color: black;
}
.mixin(@a) when (lightness
(@a) < 50%) {
background-color: white;
}
.mixin(@a) { color: @a; }
.class2 { .mixin(#ddd) }
.class2 { .mixin(#555) }
.class1 {
background-color: black;
color: #ddd;
}
.class2 {
background-color: white;
color: #555;
}
CSS (outputs)LESS
● Conditional mixins
○ Additionally, the default function may be used
to make a mixin match depending on other mixing
matches, and you may use it to create
"conditional mixins" similar to else or default
statements (of if and case structures
respectively):
Mixin Guards (2/3)
.mixin (@a) when (@a > 0) { ... }
.mixin (@a) when (default()) { ... } // apply when @a <= 0
● Guard comparison operators
○ > : greater than
○ >= : greater than or equal to
○ = : equal to
○ =< : little than or equal to
○ < : little than
● Guard logical operators
○ and : and logical operator
○ , : or logical operator
● Type checking functions
○ iscolor(), isnumber, isstring, iskeyword, isurl,
ispixel, ispercentage, isem, isunit
Mixin Guards (3/3)
● Example 1
Loops (1/2)
.loop(@counter) when (@counter > 0) {
.loop((@counter - 1));
width: (10px * @counter);
}
div {
.loop(5);
}
div {
width: 10px;
width: 20px;
width: 30px;
width: 40px;
width: 50px;
}
LESS CSS (outputs)
● Example 2
Loops (2/2)
.generate-columns(4);
.generate-columns(@n, @i: 1) when (@i =< @n) {
.column-@{i} {
width: (@i * 100% / @n);
}
.generate-columns(@n, (@i + 1));
}
LESS
.column-1 { width: 25%; }
.column-2 { width: 50%; }
.column-3 { width: 75%; }
.column-4 { width: 100%; }
CSS (outputs)
● Comma
Merge (1/2)
.mixin() {
box-shadow+: inset 0 0 10px #555;
}
.myclass {
.mixin();
box-shadow+: 0 0 20px black;
}
LESS
.myclass {
box-shadow: inset 0 0 10px #555, 0 0 20px black;
}
CSS (outputs)
● Space
Merge (2/2)
.mixin() {
transform+_: scale(2);
}
.myclass {
.mixin();
transform+_: rotate(15deg);
}
LESS
.myclass {
transform: scale(2) rotate(15deg);
}
CSS (outputs)
● Online Compiler
○ http://winless.org/online-less-compiler
● GUIs Compiler
○ WinLess
○ Crunch!
○ Mixture
○ …
● For more, go to
○ http://lesscss.org/usage/#guis-for-less
Compile LESS to CSS
● Using LESS define a button using mixin
and can be changed the button style from
color blue to any giving color
TODO
Default Button Mouse Over Button
● http://lesscss.org/features/
● http://css-tricks.com/snippets/javascript/lighten-darken-color/
● https://stackoverflow.com/questions/21821947/calculate-difference-
between-color-hexadecimal/21831435#21831435
● https://github.com/less/less.js/archive/master.zip
●
References

More Related Content

What's hot

LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS Preprocessor
Andrea Tarr
 
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
Claudina Sarahe
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
Lucien Lee
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
Mario Noble
 
Landing Pages 101
Landing Pages 101Landing Pages 101
Landing Pages 101
Celeste Horgan
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
Wynn Netherland
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
Rachel Andrew
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
joilrahat
 
10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site
Morten Rand-Hendriksen
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3
Nur Fadli Utomo
 
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
 
Compile your Style
Compile your StyleCompile your Style
Compile your Style
Ragnar Kurm
 
Css frameworks
Css frameworksCss frameworks
Css frameworks
Dimitar Belchugov
 
Web Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at GoogleWeb Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at Google
Estelle Weyl
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
CSS in React
CSS in ReactCSS in React
CSS in React
Joe Seifi
 
Confoo: You can use CSS for that!
Confoo: You can use CSS for that!Confoo: You can use CSS for that!
Confoo: You can use CSS for that!
Rachel Andrew
 
Taming CSS Selectors
Taming CSS SelectorsTaming CSS Selectors
Taming CSS Selectors
Nicole Sullivan
 

What's hot (20)

LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS Preprocessor
 
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
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Landing Pages 101
Landing Pages 101Landing Pages 101
Landing Pages 101
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
CSS Grid Layout
CSS Grid LayoutCSS Grid Layout
CSS Grid Layout
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
 
10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site
 
Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3Pemrograman Web 4 - Bootstrap 3
Pemrograman Web 4 - Bootstrap 3
 
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)
 
Compile your Style
Compile your StyleCompile your Style
Compile your Style
 
Css frameworks
Css frameworksCss frameworks
Css frameworks
 
Web Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at GoogleWeb Development for Mobile: GTUG Talk at Google
Web Development for Mobile: GTUG Talk at Google
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
CSS in React
CSS in ReactCSS in React
CSS in React
 
Confoo: You can use CSS for that!
Confoo: You can use CSS for that!Confoo: You can use CSS for that!
Confoo: You can use CSS for that!
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Sass, Compass
Sass, CompassSass, Compass
Sass, Compass
 
Taming CSS Selectors
Taming CSS SelectorsTaming CSS Selectors
Taming CSS Selectors
 

Similar to LESS CSS Pre-processor

Less css framework
Less css frameworkLess css framework
Less css framework
Manisha Bano
 
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
Sanjoy Kr. Paul
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
Eugene Nor
 
An empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessorsAn empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessors
Nikolaos Tsantalis
 
Theming Ext JS 4
Theming Ext JS 4Theming Ext JS 4
Theming Ext JS 4
Sencha
 
Ext js saas&compass
Ext js saas&compassExt js saas&compass
Ext js saas&compass
elitonweb
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
jdramaix
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
Arcbees
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
Nicolas Buduroi
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
David Engel
 
Introduction to GGVIS Visualization
Introduction to GGVIS VisualizationIntroduction to GGVIS Visualization
Introduction to GGVIS Visualization
HemantSingh311
 
Python for web security - beginner
Python for web security - beginnerPython for web security - beginner
Python for web security - beginner
Sanjeev Kumar Jaiswal
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
Vikas Sharma
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)SANTOSH RATH
 
Into The Box 2018 - CBT
Into The Box 2018 - CBTInto The Box 2018 - CBT
Into The Box 2018 - CBT
Ortus Solutions, Corp
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Data Con LA
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
Selvin Josy Bai Somu
 
JavaScript
JavaScriptJavaScript
JavaScript
Reem Alattas
 
Sencha Touch
Sencha TouchSencha Touch
Sencha Touch
Craig Walker
 

Similar to LESS CSS Pre-processor (20)

Less css framework
Less css frameworkLess css framework
Less css framework
 
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
 
Write LESS. DO more.
Write LESS. DO more.Write LESS. DO more.
Write LESS. DO more.
 
An empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessorsAn empirical study on the use of CSS preprocessors
An empirical study on the use of CSS preprocessors
 
Theming Ext JS 4
Theming Ext JS 4Theming Ext JS 4
Theming Ext JS 4
 
Ext js saas&compass
Ext js saas&compassExt js saas&compass
Ext js saas&compass
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
 
Css3 and gwt in perfect harmony
Css3 and gwt in perfect harmonyCss3 and gwt in perfect harmony
Css3 and gwt in perfect harmony
 
Lobos Introduction
Lobos IntroductionLobos Introduction
Lobos Introduction
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
Introduction to GGVIS Visualization
Introduction to GGVIS VisualizationIntroduction to GGVIS Visualization
Introduction to GGVIS Visualization
 
Python for web security - beginner
Python for web security - beginnerPython for web security - beginner
Python for web security - beginner
 
copa-ii.pptx
copa-ii.pptxcopa-ii.pptx
copa-ii.pptx
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)
 
Into The Box 2018 - CBT
Into The Box 2018 - CBTInto The Box 2018 - CBT
Into The Box 2018 - CBT
 
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
Big Data Day LA 2015 - Compiling DSLs for Diverse Execution Environments by Z...
 
Client sidescripting javascript
Client sidescripting javascriptClient sidescripting javascript
Client sidescripting javascript
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Sencha Touch
Sencha TouchSencha Touch
Sencha Touch
 

Recently uploaded

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 

Recently uploaded (20)

JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 

LESS CSS Pre-processor

  • 2. ● Introduction ● Variables ● Operations ● Functions ● Extend ● Mixins ● Loops ● Merge ● Compile LESS to CSS ● TODO Outline
  • 3. ● What is LESS? ○ Less is a CSS pre-processor, meaning that it extends the CSS language, adding features that allow variables, mixins, functions and many other techniques that allow you to make CSS that is more maintainable, themeable and extendible. ● Usage Development Mode Introduction LESS <link rel="stylesheet/less" type="text/css" href="styles.less" /> Library <script src="less.js" type="text/javascript"></script>
  • 4. ● Color Variables (1/7) // Variables @link-color: #0000ff; @btn-color: white; // Usage a { color: @link-color; } button { color: @btn-color; background: @link-color; } LESS // Outputs a { color: #0000ff; } button { color: #ffffff; background: #0000ff; } CSS (outputs)
  • 5. ● URLs Variables (2/7) // Variables @images: "../img"; // Usage button { background: url("@{images}/button_blue.png"); } LESS // Outputs button { background: url("../img/button_blue.png"); } CSS (outputs)
  • 6. ● Selectors Variables (3/7) // Variables @mySelector: banner; // Usage .@{mySelector} { font-weight: bold; line-height: 40px; margin: 0 auto; } LESS // Outputs .banner { font-weight: bold; line-height: 40px; margin: 0 auto; } CSS (outputs)
  • 7. ● Properties Variables (4/7) // Variable @property: color; // Usage .widget { @{property}: #0ee; background-@{property}: #999; } LESS // Outputs .widget { color: #0ee; background-color: #999; } CSS (outputs)
  • 8. ● Variable Names Variables (5/7) // Variable @fnord: "I am fnord."; @var: "fnord"; // Usage .text { content: @@var; } LESS // Outputs .text { content: "I am fnord."; } CSS (outputs)
  • 9. ● Lazy Loading ○ Variables are lazy loaded and do not have to be declared before being used. Variables (6/7) .lazy-eval { width: @var; } @var: @a; @a: 9%; LESS .lazy-eval-scope { width: 9%; } CSS (outputs)
  • 10. ● @import ○ Import styles from other style sheets Variables (7/7) @import "foo"; // foo.less is imported @import "foo.less"; // foo.less is imported @import "foo.php"; // foo.php imported as a less file @import "foo.css"; // statement left in place, as-is
  • 11. Operations @base: 5%; // Outputs @filler: @base * 2; // 10% @other: @base + @filler; // 15% @base-color: #222; // @padding: 5px; // color: #888 / 4; // #222222 background-color: @base-color + #111; // #333333 height: 100% / 2 + @filler; // 60% padding: @padding + 5; // 10px // Question??? margin: @base + @padding; // what is it?
  • 12. ● http://lesscss.org/functions/ Functions @base: #0000ff; @width: 0.5; .class { width: percentage(@width); // 50% color: greyscale(@base, 5%); // #838383 background-color: lighten(@base, 25%); // #8080ff } // Output .class { width: 50%; color: #838383; background-color: #8080ff; }
  • 13. ● Example 1 Extend (1/2) nav ul { &:extend(.inline); background: blue; } .inline { color: red; } LESS nav ul { background: blue; } .inline, nav ul { color: red; } CSS (outputs)
  • 14. ● Example 2 Extend (2/2) nav ul:extend(.inline) { background: blue; } .inline { color: red; } LESS nav ul { background: blue; } .inline, nav ul { color: red; } CSS (outputs)
  • 15. ● Mixin ● Parametric Mixins ● Mixins as Functions ● Mixin Guards Mixin Outline
  • 16. ● "mix-in" properties from existing styles Mixins (1/3) .a { color: red; } #b { background: blue; } .mixin-class { .a(); } .mixin-id { #b(); } LESS .a { color: red; } #b { background: blue; } .mixin-class { color: red; } .mixin-id { background: blue; } CSS (outputs)
  • 17. ● Not outputting the mixin Mixins (2/3) .my-mixin { color: black; } .my-other-mixin() { background: white; } .class { .my-mixin; .my-other-mixin; } .my-mixin { color: black; } .class { color: black; background: white; } CSS (outputs)LESS
  • 18. ● Selectors in mixins Mixins (3/3) .my-hover-mixin() { &:hover { border: 1px solid red; } color: white; } button { .my-hover-mixin(); background: blue; } button { color: white; background: blue; } button:hover { border: 1px solid red; } CSS (outputs)LESS
  • 19. ● How to pass arguments to mixins Parametric Mixins (1/3) .border-radius(@radius) { -webkit-border-radius: @radius; -moz-border-radius: @radius; border-radius: @radius; } .button { .border-radius(6px); } LESS CSS (outputs) .button { -webkit-border-radius: 6px; -moz-border-radius: 6px; border-radius: 6px; } CSS (outputs)
  • 20. ● How to set default parameters to mixins Parametric Mixins (2/3) .border-radius(@radius: 5px) { -webkit-border-radius: @radius; -moz-border-radius: @radius; border-radius: @radius; } .button { .border-radius(); } LESS CSS (outputs) .button { -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; } CSS (outputs)
  • 21. ● Mixins with Multiple Parameters Parametric Mixins (3/3) .mixin(@color; @padding) { color: @color; padding: @padding; } .some .selector div { .mixin(blue, 2px); } LESS CSS (outputs) .some .selector div { color: blue; padding: 2px; } CSS (outputs)
  • 22. ● Return variables Mixins as Functions (1/3) .mixin() { @width: 100%; @height: 200px; } .caller { .mixin(); width: @width; height: @height; } .caller { width: 100%; height: 200px; } CSS (outputs)LESS
  • 23. ● Return mixin defined in mixin Mixins as Functions (2/3) .unlock(@value) { .doSomething() { padding: @value; } } #namespace { .unlock(5px); .doSomething(); } #namespace { padding: 5px; } CSS (outputs)LESS
  • 24. ● Overridden global variables Mixins as Functions (3/3) @size: 10px; .mixin() { @size: 5px; @inMixin: 20px; } .class { margin: @size @inMixin; .mixin(); } .other-class { margin: @size; } .class { margin: 5px 20px; } .other-class { margin: 10px; } CSS (outputs)LESS
  • 25. ● Conditional mixins Mixin Guards (1/3) .mixin(@a) when (lightness (@a) >= 50%) { background-color: black; } .mixin(@a) when (lightness (@a) < 50%) { background-color: white; } .mixin(@a) { color: @a; } .class2 { .mixin(#ddd) } .class2 { .mixin(#555) } .class1 { background-color: black; color: #ddd; } .class2 { background-color: white; color: #555; } CSS (outputs)LESS
  • 26. ● Conditional mixins ○ Additionally, the default function may be used to make a mixin match depending on other mixing matches, and you may use it to create "conditional mixins" similar to else or default statements (of if and case structures respectively): Mixin Guards (2/3) .mixin (@a) when (@a > 0) { ... } .mixin (@a) when (default()) { ... } // apply when @a <= 0
  • 27. ● Guard comparison operators ○ > : greater than ○ >= : greater than or equal to ○ = : equal to ○ =< : little than or equal to ○ < : little than ● Guard logical operators ○ and : and logical operator ○ , : or logical operator ● Type checking functions ○ iscolor(), isnumber, isstring, iskeyword, isurl, ispixel, ispercentage, isem, isunit Mixin Guards (3/3)
  • 28. ● Example 1 Loops (1/2) .loop(@counter) when (@counter > 0) { .loop((@counter - 1)); width: (10px * @counter); } div { .loop(5); } div { width: 10px; width: 20px; width: 30px; width: 40px; width: 50px; } LESS CSS (outputs)
  • 29. ● Example 2 Loops (2/2) .generate-columns(4); .generate-columns(@n, @i: 1) when (@i =< @n) { .column-@{i} { width: (@i * 100% / @n); } .generate-columns(@n, (@i + 1)); } LESS .column-1 { width: 25%; } .column-2 { width: 50%; } .column-3 { width: 75%; } .column-4 { width: 100%; } CSS (outputs)
  • 30. ● Comma Merge (1/2) .mixin() { box-shadow+: inset 0 0 10px #555; } .myclass { .mixin(); box-shadow+: 0 0 20px black; } LESS .myclass { box-shadow: inset 0 0 10px #555, 0 0 20px black; } CSS (outputs)
  • 31. ● Space Merge (2/2) .mixin() { transform+_: scale(2); } .myclass { .mixin(); transform+_: rotate(15deg); } LESS .myclass { transform: scale(2) rotate(15deg); } CSS (outputs)
  • 32. ● Online Compiler ○ http://winless.org/online-less-compiler ● GUIs Compiler ○ WinLess ○ Crunch! ○ Mixture ○ … ● For more, go to ○ http://lesscss.org/usage/#guis-for-less Compile LESS to CSS
  • 33. ● Using LESS define a button using mixin and can be changed the button style from color blue to any giving color TODO Default Button Mouse Over Button
  • 34. ● http://lesscss.org/features/ ● http://css-tricks.com/snippets/javascript/lighten-darken-color/ ● https://stackoverflow.com/questions/21821947/calculate-difference- between-color-hexadecimal/21831435#21831435 ● https://github.com/less/less.js/archive/master.zip ● References