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