SlideShare uma empresa Scribd logo
1 de 24
Introduction to LESS
DYNAMIC STYLESHEET LANGUAGE – COMPILES TO CSS
1
AGENDA 2
# Problems writing plain CSS
# LESS
PROBLEMS WRITING PLAIN CSS 3
# No option for variables
# No option for reusable CSS
# Duplication of Code
# No option to debug CSS code
# No option to perform calculations in CSS
# Hard to maintain even for minor changes
# Imports make request to fetch CSS files
DYNAMIC STYLESHEET LANGUAGES 4
# Better ways to write CSS
# Option for named variables
# Option for creating reusable CSS
# Clear CSS rules cascading
# Option to perform calculations in CSS
# Combine CSS files rather than using import
LESS IS MORE 5
# Compiles to CSS
# Programming features in CSS
# Feels like writing CSS
# CSS is valid LESS
# LESS on Client
# LESS on Server
# Importing
# Variables
# Functions
# Operations
# Mixins
# Nested Rules
# Other features
LESS ON CLIENT 6
<head>
<link rel=“stylesheet/less” type=“text/css” href=“home.less”
/>
<script src=“js/less.js” type=“text/javascript”></script>
</head>
LESS ON SERVER 7
ASP.NET via NuGet
>install-package dotless
# Preferred More
# Server Support
# Node.js
# ASP.NET
# Rails
# JSP
BASIC LESS 8
@headerFontSize: 16px;
// single line comments
#nestedRules{
.childElements{
font-size: @headerFontSize;
}
}
LESS VARIABLES 9
@redColor: red; //Named Colors
@myFontSize: 4px; //px Unit
@boxLineHeight: 2pt; //pt/em Unit
@thatColor: #ffccff; //Hex colors
@myFontType: Comic Sans, sans serif; //Strings
@comValue: 2px solid green; //Complex strings
Variables are actually constants in LESS. No reassignments.
@boxLineHeight: @boxLineHeight + 2; //Doesn’t work
LESS OPERATIONS 10
font-size: 10pt + 2;
color: #fff / 4;
width: (100% / 4) + 5%;
font-size: @myFontSize + 4;
color: @myRedColor / 10;
LESS FUNCTIONS - COLORS 11
color: lighten(@myColor, 5%)
color: darken(@myColor, 5%)
color: saturate(@myColor, 5%)
color: desaturate(@myColor, 5%)
color: fadein(@myColor, 5%)
color: fadeout(@myColor, 5%)
color: fade(@myColor, 5%)
color: spin(@myColor, 5%)
color: mix(@myColor, #fff)
LESS FUNCTIONS - MORE 12
@hue: hue(@myColor);
@sat: saturation(@myColor);
@light: lightness(@myColor);
@alpha: alpha(@myColor);
@newColor: hsl(10%, 5%, 30%);
@roundMoney: round(9.99);
@topMoney: ceil(19.45);
@floorMoney: floor(29.90);
@percentMoney: percentage(.5);
LESS MIXINS 13
.rounded_corners(@curveSize) {
border-radius: @curveSize;
-moz-border-radius: @curveSize;
-webkit-border-radius: @curveSize;
}
#myDiv {
.rounded-corners(15px);
}
#myBox {
.rounded-corners(5px);
}
# Reusable components
# Look like Functions
# Accepts parameters
# Can set default values
# Can be overloaded
LESS MIXINS – DEFAULT VALUE 14
.rounded_corners(@curveSize: 5px) {
border-radius: @curveSize;
-moz-border-radius: @curveSize;
-webkit-border-radius: @curveSize;
}
#myDiv {
.rounded-corners(15px);
}
#myBox {
.rounded-corners;
}
LESS MIXINS – OVERLOADS 15
.myBoxColor(@myColor) {
color: @myColor;
}
.myBoxColor(@myColor, @changePer) {
color: darken(@myColor, @changePer);
}
#myDiv {
.myBoxColor(#ccc, 20%);
}
LESS MIXINS – GUARDS 16
.myBoxColor(@myColor) when (lightness(@myColor) >= 50%) {
color: darken(@myColor, 50%);
}
.myBoxColor(@myColor) when (lightness(@myColor) < 50%) {
color: lighten(@myColor, 50%);
}
#myDiv {
.myBoxColor(#ccc);
}
LESS MIXINS – TYPE GUARDS 17
.myBoxWidth(@size) when (isnumber(@size)) {
width: @size * 4;
}
.myBoxWidth(@size) when (ispercentage(@size)) {
width: @size;
}
#myDiv {
.myBoxWidth(30%);
}
LESS NESTED RULES 18
// LESS
#navigation {
float: right;
font-size: 12px;
ul {
list-style-type: none;
li {
margin: 5px;
}
}
}
/* CSS */
#navigation {
float: right;
font-size: 12px;
}
#navigation ul {
list-style-type: none;
}
#navigation ul li {
margin:5px;
}
LESS NESTED RULES – COMBINATOR 19
a {
color: red;
&:hover {
color: green;
}
}
//output
a { color: red; }
a:hover { color: green; }
LESS NAMESPACES 20
#forms-namespace {
.submit-button {
background-color: blue;
border: 1px solid red;
}
}
//namespaces for grouping, does not actually compile as CSS
#my-submit-button {
#forms-namespace > .submit-button;
}
LESS SCOPING 21
@myFontSize: 20px;
#forms-namespace {
@myFontSize: 15px;
.submit-button {
font-size:@myFontSize; // 15px;
}
}
//Variables are Scoped
//Mixins are also Scoped
LESS STRING INTERPOLATION 22
@assets: “/assets/images/”;
#form {
background: url(“@{assets}mybackground.jpg”);
}
//Back quotes to execute JS
@up-root: `”@{assets}”.toUpperCase()`;
LESS SUMMARY 23
# Developer way of writing CSS
# Maintainable CSS
# Reusable and Readable Code
# Structure CSS
# Modularize CSS
# Adds more to CSS
Manish
Shekhawat

Mais conteúdo relacionado

Destaque

PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試
PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試
PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試亮亮 閃
 
OpenGL ES Presentation
OpenGL ES PresentationOpenGL ES Presentation
OpenGL ES PresentationEric Cheng
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.Girish Ghate
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android Arvind Devaraj
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadTristan Lorach
 
OpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionOpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionChamp Yen
 
HTML5 로 iPhone App 만들기
HTML5 로 iPhone App 만들기HTML5 로 iPhone App 만들기
HTML5 로 iPhone App 만들기JungHyuk Kwon
 
jQTouch – Mobile Web Apps with HTML, CSS and JavaScript
jQTouch – Mobile Web Apps with HTML, CSS and JavaScriptjQTouch – Mobile Web Apps with HTML, CSS and JavaScript
jQTouch – Mobile Web Apps with HTML, CSS and JavaScriptPhilipp Bosch
 
Apache web server
Apache web serverApache web server
Apache web serverzrstoppe
 
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsVolodymyr Voytyshyn
 
HTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsHTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsSun Technlogies
 

Destaque (20)

PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試
PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試
PHP也有day #27 - From apprentice to artisan 解耦合處理程序及單元測試
 
OpenGL ES Presentation
OpenGL ES PresentationOpenGL ES Presentation
OpenGL ES Presentation
 
OpenGL Introduction.
OpenGL Introduction.OpenGL Introduction.
OpenGL Introduction.
 
OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android OpenGLES - Graphics Programming in Android
OpenGLES - Graphics Programming in Android
 
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver OverheadOpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
OpenGL NVIDIA Command-List: Approaching Zero Driver Overhead
 
OpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming IntroductionOpenGL ES 2.x Programming Introduction
OpenGL ES 2.x Programming Introduction
 
HTML5 로 iPhone App 만들기
HTML5 로 iPhone App 만들기HTML5 로 iPhone App 만들기
HTML5 로 iPhone App 만들기
 
jQTouch – Mobile Web Apps with HTML, CSS and JavaScript
jQTouch – Mobile Web Apps with HTML, CSS and JavaScriptjQTouch – Mobile Web Apps with HTML, CSS and JavaScript
jQTouch – Mobile Web Apps with HTML, CSS and JavaScript
 
Apache web server
Apache web serverApache web server
Apache web server
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Less is beautiful
Less is beautifulLess is beautiful
Less is beautiful
 
jQuery PPT
jQuery PPTjQuery PPT
jQuery PPT
 
Modern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design PatternsModern JavaScript Applications: Design Patterns
Modern JavaScript Applications: Design Patterns
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
OpenGL Basics
OpenGL BasicsOpenGL Basics
OpenGL Basics
 
Apache ppt
Apache pptApache ppt
Apache ppt
 
PHP Web Programming
PHP Web ProgrammingPHP Web Programming
PHP Web Programming
 
HTML5 Essentials
HTML5 EssentialsHTML5 Essentials
HTML5 Essentials
 
HTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts BasicsHTML, CSS and Java Scripts Basics
HTML, CSS and Java Scripts Basics
 
Up to Speed on HTML 5 and CSS 3
Up to Speed on HTML 5 and CSS 3Up to Speed on HTML 5 and CSS 3
Up to Speed on HTML 5 and CSS 3
 

Semelhante a Introduction to LESS

Doing More With Less
Doing More With LessDoing More With Less
Doing More With LessDavid Engel
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPressJames Steinbach
 
LESS is More
LESS is MoreLESS is More
LESS is Morejsmith92
 
LESS(CSS preprocessor)
LESS(CSS preprocessor)LESS(CSS preprocessor)
LESS(CSS preprocessor)VIPIN KUMAR
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesDinu Suman
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nlHans Kuijpers
 
Raleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass PresentationRaleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass PresentationDaniel Yuschick
 
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
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
UI Realigning & Refactoring by Jina Bolton
UI Realigning & Refactoring by Jina BoltonUI Realigning & Refactoring by Jina Bolton
UI Realigning & Refactoring by Jina BoltonCodemotion
 
Less js-&-wp
Less js-&-wpLess js-&-wp
Less js-&-wprfair404
 

Semelhante a Introduction to LESS (20)

A better CSS: Sass and Less - CC FE & UX
A better CSS: Sass and Less - CC FE & UXA better CSS: Sass and Less - CC FE & UX
A better CSS: Sass and Less - CC FE & UX
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
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
 
Why less?
Why less?Why less?
Why less?
 
Do more with {less}
Do more with {less}Do more with {less}
Do more with {less}
 
LESS is More
LESS is MoreLESS is More
LESS is More
 
LESS(CSS preprocessor)
LESS(CSS preprocessor)LESS(CSS preprocessor)
LESS(CSS preprocessor)
 
CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
Software programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS filesSoftware programming tools for creating/managing CSS files
Software programming tools for creating/managing CSS files
 
CSS with LESS for #jd13nl
CSS with LESS for #jd13nlCSS with LESS for #jd13nl
CSS with LESS for #jd13nl
 
Raleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass PresentationRaleigh Web Design Meetup Group - Sass Presentation
Raleigh Web Design Meetup Group - Sass Presentation
 
Advanced sass
Advanced sassAdvanced sass
Advanced sass
 
Less css
Less cssLess css
Less css
 
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
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
UI Realigning & Refactoring by Jina Bolton
UI Realigning & Refactoring by Jina BoltonUI Realigning & Refactoring by Jina Bolton
UI Realigning & Refactoring by Jina Bolton
 
Css frameworks
Css frameworksCss frameworks
Css frameworks
 
Less js-&-wp
Less js-&-wpLess js-&-wp
Less js-&-wp
 

Último

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Introduction to LESS

  • 1. Introduction to LESS DYNAMIC STYLESHEET LANGUAGE – COMPILES TO CSS 1
  • 2. AGENDA 2 # Problems writing plain CSS # LESS
  • 3. PROBLEMS WRITING PLAIN CSS 3 # No option for variables # No option for reusable CSS # Duplication of Code # No option to debug CSS code # No option to perform calculations in CSS # Hard to maintain even for minor changes # Imports make request to fetch CSS files
  • 4. DYNAMIC STYLESHEET LANGUAGES 4 # Better ways to write CSS # Option for named variables # Option for creating reusable CSS # Clear CSS rules cascading # Option to perform calculations in CSS # Combine CSS files rather than using import
  • 5. LESS IS MORE 5 # Compiles to CSS # Programming features in CSS # Feels like writing CSS # CSS is valid LESS # LESS on Client # LESS on Server # Importing # Variables # Functions # Operations # Mixins # Nested Rules # Other features
  • 6. LESS ON CLIENT 6 <head> <link rel=“stylesheet/less” type=“text/css” href=“home.less” /> <script src=“js/less.js” type=“text/javascript”></script> </head>
  • 7. LESS ON SERVER 7 ASP.NET via NuGet >install-package dotless # Preferred More # Server Support # Node.js # ASP.NET # Rails # JSP
  • 8. BASIC LESS 8 @headerFontSize: 16px; // single line comments #nestedRules{ .childElements{ font-size: @headerFontSize; } }
  • 9. LESS VARIABLES 9 @redColor: red; //Named Colors @myFontSize: 4px; //px Unit @boxLineHeight: 2pt; //pt/em Unit @thatColor: #ffccff; //Hex colors @myFontType: Comic Sans, sans serif; //Strings @comValue: 2px solid green; //Complex strings Variables are actually constants in LESS. No reassignments. @boxLineHeight: @boxLineHeight + 2; //Doesn’t work
  • 10. LESS OPERATIONS 10 font-size: 10pt + 2; color: #fff / 4; width: (100% / 4) + 5%; font-size: @myFontSize + 4; color: @myRedColor / 10;
  • 11. LESS FUNCTIONS - COLORS 11 color: lighten(@myColor, 5%) color: darken(@myColor, 5%) color: saturate(@myColor, 5%) color: desaturate(@myColor, 5%) color: fadein(@myColor, 5%) color: fadeout(@myColor, 5%) color: fade(@myColor, 5%) color: spin(@myColor, 5%) color: mix(@myColor, #fff)
  • 12. LESS FUNCTIONS - MORE 12 @hue: hue(@myColor); @sat: saturation(@myColor); @light: lightness(@myColor); @alpha: alpha(@myColor); @newColor: hsl(10%, 5%, 30%); @roundMoney: round(9.99); @topMoney: ceil(19.45); @floorMoney: floor(29.90); @percentMoney: percentage(.5);
  • 13. LESS MIXINS 13 .rounded_corners(@curveSize) { border-radius: @curveSize; -moz-border-radius: @curveSize; -webkit-border-radius: @curveSize; } #myDiv { .rounded-corners(15px); } #myBox { .rounded-corners(5px); } # Reusable components # Look like Functions # Accepts parameters # Can set default values # Can be overloaded
  • 14. LESS MIXINS – DEFAULT VALUE 14 .rounded_corners(@curveSize: 5px) { border-radius: @curveSize; -moz-border-radius: @curveSize; -webkit-border-radius: @curveSize; } #myDiv { .rounded-corners(15px); } #myBox { .rounded-corners; }
  • 15. LESS MIXINS – OVERLOADS 15 .myBoxColor(@myColor) { color: @myColor; } .myBoxColor(@myColor, @changePer) { color: darken(@myColor, @changePer); } #myDiv { .myBoxColor(#ccc, 20%); }
  • 16. LESS MIXINS – GUARDS 16 .myBoxColor(@myColor) when (lightness(@myColor) >= 50%) { color: darken(@myColor, 50%); } .myBoxColor(@myColor) when (lightness(@myColor) < 50%) { color: lighten(@myColor, 50%); } #myDiv { .myBoxColor(#ccc); }
  • 17. LESS MIXINS – TYPE GUARDS 17 .myBoxWidth(@size) when (isnumber(@size)) { width: @size * 4; } .myBoxWidth(@size) when (ispercentage(@size)) { width: @size; } #myDiv { .myBoxWidth(30%); }
  • 18. LESS NESTED RULES 18 // LESS #navigation { float: right; font-size: 12px; ul { list-style-type: none; li { margin: 5px; } } } /* CSS */ #navigation { float: right; font-size: 12px; } #navigation ul { list-style-type: none; } #navigation ul li { margin:5px; }
  • 19. LESS NESTED RULES – COMBINATOR 19 a { color: red; &:hover { color: green; } } //output a { color: red; } a:hover { color: green; }
  • 20. LESS NAMESPACES 20 #forms-namespace { .submit-button { background-color: blue; border: 1px solid red; } } //namespaces for grouping, does not actually compile as CSS #my-submit-button { #forms-namespace > .submit-button; }
  • 21. LESS SCOPING 21 @myFontSize: 20px; #forms-namespace { @myFontSize: 15px; .submit-button { font-size:@myFontSize; // 15px; } } //Variables are Scoped //Mixins are also Scoped
  • 22. LESS STRING INTERPOLATION 22 @assets: “/assets/images/”; #form { background: url(“@{assets}mybackground.jpg”); } //Back quotes to execute JS @up-root: `”@{assets}”.toUpperCase()`;
  • 23. LESS SUMMARY 23 # Developer way of writing CSS # Maintainable CSS # Reusable and Readable Code # Structure CSS # Modularize CSS # Adds more to CSS