SlideShare a Scribd company logo
START USING LESS CSS
By: Ali MasudianPour <masud.amp@gmail.com>

LESS CSS - A BASIC INTRODUCTION

1
WHAT IS LESS CSS
•

Dynamic CSS
• Less is a “dynamic stylesheet language”

•

LESS extends CSS with dynamic behavior such as variables, mixins, operations and
functions.

•

LESS runs on both the server-side (with Node.js and Rhino) or client-side (modern
browsers only)

LESS CSS - A BASIC INTRODUCTION

2
COMPILING IN BROWSER
•

Less.js will perform AJAX requests to grab your Less files, will then process those files to
convert them into CSS, and finally inject the resulting CSS in the head of your document.

•

There is a bad thing about it
•

if the user‟s JavaScript is deactivated, it will not work!

LESS CSS - A BASIC INTRODUCTION

3
LET‟S START
•

LESS codes are written into a file with .less extension

•

Variables

• Less variables can be declared and used with the @ symbol.
• Example:
@white: #fff;

.class{
background-color:@white;
}

LESS CSS - A BASIC INTRODUCTION

4
LET‟S START
•

In addition, we can assign a variable to another
•

For instance:
•

•

@myDefaultColor:@white;

MIXINS
•

With Less we can define “mixins”, which are something comparable to functions in other programming languages. In Less they‟re used
to group CSS instructions.
.Round{
-webkit-border-radius:9999px;
-moz-border-radius:9999px;
border-radius:9999px;
}
#shape1{
.Round;
}
That‟s really simple!

LESS CSS - A BASIC INTRODUCTION

5
PARAMETRIC MIXINS
•

In LESS we can define parametric mixins. So we can send parameters through mixins
•

Example:
@defaultRadius:30px;
.RoundedShape(@radius:@defaultRadius){
-webkit-border-radius:@radius;
-moz-border-radius:@radius;

border-radius:@radius;
}
•

What an incredible feature!

LESS CSS - A BASIC INTRODUCTION

6
PARAMETRIC MIXINS
.Round{
.RoundedShape(9999px);

}
.RoundedSquare(@radius:@defaultRadius){

.RoundedShape(@radius);
}

LESS CSS - A BASIC INTRODUCTION

7
OPERATIONS
•

One other powerful feature of Less is the ability to use mathematical operations in your
stylesheets.

•

You can add, subtract, multiply and divide values

•

Example
@defaultShapesWidth:200px;
@borderSize:@defaultShapesWidth * 0.1;

•

it also works for colors
@defaultThemeColor:@lightBlue;
@borderColor:@defaultThemeColor - #222;

LESS CSS - A BASIC INTRODUCTION

8
COLOR FUNCTIONS
•

Less provides the following color functions:
•

darken() and lighten(), which add some black or white

•

saturate() and desaturate(), to make a color more colorful or more grayscale

•

Fadein() and fadeout, to increase or reduce transparency

•

Spin(), which modifies the hue of the color
• Examples:
@borderColor: desaturate(@defaultColor,100%)
@borderColor: darken(desaturate($defaultColort,100%),20%)
@defaultColor:spin(@mycolor1,100)

LESS CSS - A BASIC INTRODUCTION

9
NESTED RULES
•

When designing a complex page using css, you often have to chain selectors to aim a particular element in the DOM, like
this:
#header h1{}
#main h1{}
•

With LESS you can nest rules inside parent rules to mimic the DOM structure:
#header {
h1{}
}

.shape{
}
•

&:hover{background-color:@myColor;}
This & symbol represents the current selected elements. It is the equivalent of “THIS” in most programming language

LESS CSS - A BASIC INTRODUCTION

10
IMPORTING
•

It is a very good practice to separate your rules into different files instead of having a
1000 lines file.

•

Importing a file into another LESS is as simple as that:
• @import “file2.less”;

•

You can even omit the .less extension and just declare:

• @import “file2”;

LESS CSS - A BASIC INTRODUCTION

11
MODIFY VARIABLES
•

modifyVars enables modification of LESS variables in run-time.

•

When called with new value, the LESS file is recompiled without reloading.

•

Usage:
Less.modifyVars({
„@color1‟:‟red‟,

„@color2‟: „blue‟
});

LESS CSS - A BASIC INTRODUCTION

12
THANK YOU
•

References:
• Lesscss.org

• Verekia.com

LESS CSS - A BASIC INTRODUCTION

13

More Related Content

What's hot

SASS - Syntactically Awesome Stylesheet
SASS - Syntactically Awesome StylesheetSASS - Syntactically Awesome Stylesheet
SASS - Syntactically Awesome Stylesheet
Neha Sharma
 
Sass presentation
Sass presentationSass presentation
Sass presentation
Davin Abraham
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
Kianosh Pourian
 
Bliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS Introduction
Irfan Maulana
 
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
Irfan Maulana
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
Knoldus Inc.
 
Developer skills
Developer skillsDeveloper skills
Developer skills
webger
 
The web context
The web contextThe web context
The web context
Dan Phiffer
 
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
Suzanne Dergacheva
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_phpJeanho Chu
 
Intro to css & sass
Intro to css & sassIntro to css & sass
Intro to css & sass
Sean Wolfe
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
Kianosh Pourian
 
Web programming css
Web programming cssWeb programming css
Web programming css
Uma mohan
 
SASS for WordPress Workshop
SASS for WordPress WorkshopSASS for WordPress Workshop
SASS for WordPress Workshop
Kanchha kaji Prajapati
 
Css1
Css1Css1
SharePoint 2010 branding
SharePoint 2010 brandingSharePoint 2010 branding
SharePoint 2010 branding
Phil Wicklund
 
CSS Modules
CSS ModulesCSS Modules
CSS Modules
George Bukhanov
 

What's hot (20)

SASS - Syntactically Awesome Stylesheet
SASS - Syntactically Awesome StylesheetSASS - Syntactically Awesome Stylesheet
SASS - Syntactically Awesome Stylesheet
 
Sass presentation
Sass presentationSass presentation
Sass presentation
 
Less
LessLess
Less
 
Sass presentation
Sass presentationSass presentation
Sass presentation
 
Intro to SASS CSS
Intro to SASS CSSIntro to SASS CSS
Intro to SASS CSS
 
Bliblidotcom - SASS Introduction
Bliblidotcom - SASS IntroductionBliblidotcom - SASS Introduction
Bliblidotcom - SASS Introduction
 
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
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
Developer skills
Developer skillsDeveloper skills
Developer skills
 
The web context
The web contextThe web context
The web context
 
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
 
Week01 jan19 introductionto_php
Week01 jan19 introductionto_phpWeek01 jan19 introductionto_php
Week01 jan19 introductionto_php
 
Intro to css & sass
Intro to css & sassIntro to css & sass
Intro to css & sass
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
Beautifying senc
Beautifying sencBeautifying senc
Beautifying senc
 
Web programming css
Web programming cssWeb programming css
Web programming css
 
SASS for WordPress Workshop
SASS for WordPress WorkshopSASS for WordPress Workshop
SASS for WordPress Workshop
 
Css1
Css1Css1
Css1
 
SharePoint 2010 branding
SharePoint 2010 brandingSharePoint 2010 branding
SharePoint 2010 branding
 
CSS Modules
CSS ModulesCSS Modules
CSS Modules
 

Similar to Start using less css

LESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionLESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introduction
rushi7567
 
Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introduction
rushi7567
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
David Engel
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
James Steinbach
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
Lucien Lee
 
Getting Sassy with CSS
Getting Sassy with CSSGetting Sassy with CSS
Getting Sassy with CSS
Julie Cameron
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
Nick Cooley
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
Anton Dosov
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
Anam Hossain
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!
Gill Cleeren
 
European SharePoint Webinar - Make SharePoint Sassy
European SharePoint Webinar - Make SharePoint SassyEuropean SharePoint Webinar - Make SharePoint Sassy
European SharePoint Webinar - Make SharePoint Sassy
Stefan Bauer
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y trying
James Cryer
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
kavi806657
 
LeSS in action
LeSS in actionLeSS in action
LeSS in actionPu Shiming
 
快速开发Css
快速开发Css快速开发Css
快速开发Csstbmallf2e
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
Amey Parab
 
Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
Cubet Techno Labs
 

Similar to Start using less css (20)

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
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Getting Sassy with CSS
Getting Sassy with CSSGetting Sassy with CSS
Getting Sassy with CSS
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
CSS Workflow. Pre & Post
CSS Workflow. Pre & PostCSS Workflow. Pre & Post
CSS Workflow. Pre & Post
 
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
 
Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!Comparing XAML and HTML: FIGHT!
Comparing XAML and HTML: FIGHT!
 
European SharePoint Webinar - Make SharePoint Sassy
European SharePoint Webinar - Make SharePoint SassyEuropean SharePoint Webinar - Make SharePoint Sassy
European SharePoint Webinar - Make SharePoint Sassy
 
CSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y tryingCSS Preprocessors: LESS is more or look SASS-y trying
CSS Preprocessors: LESS is more or look SASS-y trying
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
LeSS in action
LeSS in actionLeSS in action
LeSS in action
 
快速开发Css
快速开发Css快速开发Css
快速开发Css
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
CSS3
CSS3CSS3
CSS3
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
Sass_Cubet seminar
Sass_Cubet seminarSass_Cubet seminar
Sass_Cubet seminar
 

More from Ali MasudianPour

An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL database
Ali MasudianPour
 
Rapid postgresql learning, part 4
Rapid postgresql learning, part 4Rapid postgresql learning, part 4
Rapid postgresql learning, part 4Ali MasudianPour
 
Rapid postgresql learning, part 3
Rapid postgresql learning, part 3Rapid postgresql learning, part 3
Rapid postgresql learning, part 3Ali MasudianPour
 
Rapid postgresql learning, part 2
Rapid postgresql learning, part 2Rapid postgresql learning, part 2
Rapid postgresql learning, part 2Ali MasudianPour
 
Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Ali MasudianPour
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and JavaAli MasudianPour
 
Xp exterme-programming-model
Xp exterme-programming-modelXp exterme-programming-model
Xp exterme-programming-modelAli MasudianPour
 

More from Ali MasudianPour (7)

An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL database
 
Rapid postgresql learning, part 4
Rapid postgresql learning, part 4Rapid postgresql learning, part 4
Rapid postgresql learning, part 4
 
Rapid postgresql learning, part 3
Rapid postgresql learning, part 3Rapid postgresql learning, part 3
Rapid postgresql learning, part 3
 
Rapid postgresql learning, part 2
Rapid postgresql learning, part 2Rapid postgresql learning, part 2
Rapid postgresql learning, part 2
 
Rapid postgresql learning, part 1
Rapid postgresql learning, part 1Rapid postgresql learning, part 1
Rapid postgresql learning, part 1
 
A comparison between C# and Java
A comparison between C# and JavaA comparison between C# and Java
A comparison between C# and Java
 
Xp exterme-programming-model
Xp exterme-programming-modelXp exterme-programming-model
Xp exterme-programming-model
 

Recently uploaded

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
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
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
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
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
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
 
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
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 

Recently uploaded (20)

Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
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...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
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)
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
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
 
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
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

Start using less css

  • 1. START USING LESS CSS By: Ali MasudianPour <masud.amp@gmail.com> LESS CSS - A BASIC INTRODUCTION 1
  • 2. WHAT IS LESS CSS • Dynamic CSS • Less is a “dynamic stylesheet language” • LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. • LESS runs on both the server-side (with Node.js and Rhino) or client-side (modern browsers only) LESS CSS - A BASIC INTRODUCTION 2
  • 3. COMPILING IN BROWSER • Less.js will perform AJAX requests to grab your Less files, will then process those files to convert them into CSS, and finally inject the resulting CSS in the head of your document. • There is a bad thing about it • if the user‟s JavaScript is deactivated, it will not work! LESS CSS - A BASIC INTRODUCTION 3
  • 4. LET‟S START • LESS codes are written into a file with .less extension • Variables • Less variables can be declared and used with the @ symbol. • Example: @white: #fff; .class{ background-color:@white; } LESS CSS - A BASIC INTRODUCTION 4
  • 5. LET‟S START • In addition, we can assign a variable to another • For instance: • • @myDefaultColor:@white; MIXINS • With Less we can define “mixins”, which are something comparable to functions in other programming languages. In Less they‟re used to group CSS instructions. .Round{ -webkit-border-radius:9999px; -moz-border-radius:9999px; border-radius:9999px; } #shape1{ .Round; } That‟s really simple! LESS CSS - A BASIC INTRODUCTION 5
  • 6. PARAMETRIC MIXINS • In LESS we can define parametric mixins. So we can send parameters through mixins • Example: @defaultRadius:30px; .RoundedShape(@radius:@defaultRadius){ -webkit-border-radius:@radius; -moz-border-radius:@radius; border-radius:@radius; } • What an incredible feature! LESS CSS - A BASIC INTRODUCTION 6
  • 8. OPERATIONS • One other powerful feature of Less is the ability to use mathematical operations in your stylesheets. • You can add, subtract, multiply and divide values • Example @defaultShapesWidth:200px; @borderSize:@defaultShapesWidth * 0.1; • it also works for colors @defaultThemeColor:@lightBlue; @borderColor:@defaultThemeColor - #222; LESS CSS - A BASIC INTRODUCTION 8
  • 9. COLOR FUNCTIONS • Less provides the following color functions: • darken() and lighten(), which add some black or white • saturate() and desaturate(), to make a color more colorful or more grayscale • Fadein() and fadeout, to increase or reduce transparency • Spin(), which modifies the hue of the color • Examples: @borderColor: desaturate(@defaultColor,100%) @borderColor: darken(desaturate($defaultColort,100%),20%) @defaultColor:spin(@mycolor1,100) LESS CSS - A BASIC INTRODUCTION 9
  • 10. NESTED RULES • When designing a complex page using css, you often have to chain selectors to aim a particular element in the DOM, like this: #header h1{} #main h1{} • With LESS you can nest rules inside parent rules to mimic the DOM structure: #header { h1{} } .shape{ } • &:hover{background-color:@myColor;} This & symbol represents the current selected elements. It is the equivalent of “THIS” in most programming language LESS CSS - A BASIC INTRODUCTION 10
  • 11. IMPORTING • It is a very good practice to separate your rules into different files instead of having a 1000 lines file. • Importing a file into another LESS is as simple as that: • @import “file2.less”; • You can even omit the .less extension and just declare: • @import “file2”; LESS CSS - A BASIC INTRODUCTION 11
  • 12. MODIFY VARIABLES • modifyVars enables modification of LESS variables in run-time. • When called with new value, the LESS file is recompiled without reloading. • Usage: Less.modifyVars({ „@color1‟:‟red‟, „@color2‟: „blue‟ }); LESS CSS - A BASIC INTRODUCTION 12
  • 13. THANK YOU • References: • Lesscss.org • Verekia.com LESS CSS - A BASIC INTRODUCTION 13