SlideShare ist ein Scribd-Unternehmen logo
1 von 34
Downloaden Sie, um offline zu lesen
@hans2103
CSS met LESS
waar begin ik?
een presentatie voor de Joomla!dagen
21 april 2013 Woudschoten - Zeist
hans2103
Sunday 21 April 13
@hans2103
CSS met LESS
waar begin ik?
een presentatie voor de Joomla!dagen
21 april 2013 Woudschoten - Zeist
hans2103
presentatie kun je downloaden via
http://slideshare.net/hans2103
Sunday 21 April 13
@hans2103
Wat is LESS?
• LESS is een programmeertaal
• LESS compileer je naar CSS
• LESS is een CSS preprocessor
• LESS syntax is gemaakt vanuit CSS
• LESS is dynamisch CSS
Sunday 21 April 13
@hans2103
Waarom LESS gebruiken
• LESS bespaart tijd
• LESS vermindert fouten
• LESS vermindert herhalingen
• LESS is handig
Sunday 21 April 13
@hans2103
Hopsakee...
aan de slag!
veel code
Sunday 21 April 13
@hans2103
vooraf compileren
on the fly compileren
<link rel="stylesheet/css" href="style.css" />
<link rel="stylesheet/less" href="style.less" />
<script src="less.js"></script>
Sunday 21 April 13
@hans2103
style.less
// LESS
// import normalize for CSS resets
@import "normalize";
// same as @import “normalize.less”;
// import mixins
@import "mixins";
// base for mobile devices
@import "base";
//tables and small laptops
@media only screen and (min-width: 768px) {
@import "768up";
}
//desktop
@media only screen and (min-width: 1030px) {
@import "1030up";
}
Sunday 21 April 13
@hans2103@hans2103
#apt-get install node-less
http://winless.org
http://incident57.com/codekit
Sunday 21 April 13
@hans2103
clean structure with nesting
/* Compiled CSS */
#header {}
#header #nav {}
#header #nav ul {}
#header #nav ul li {}
#header #nav ul li a {}
// LESS
# header {
#nav {
ul {
li {
a {}
}
}
}
}
lijkt warempel op de HTML structuur
Sunday 21 April 13
@hans2103
clean structure with nesting
/* Compiled CSS */
a {}
a:hover {}
a:active {}
a:visited {}
// LESS
a {
&:hover {}
&:active {}
&:visited {}
}
Sunday 21 April 13
@hans2103
variables
standaard waarden om te hergebruiken in de stylesheet.
// LESS
@color: #4D926F;
@serif: serif;
@sans-serif: sans-serif;
#header {
color: @color;
font-family: @serif;
}
h2 {
color: @color;
font-family: @sans-serif;
}
/* Compiled CSS */
#header {
color: #4D926F;
font-family: serif;
}
h2 {
color: #4D926F;
font-family: sans-serif;
}
Sunday 21 April 13
@hans2103
mixins
Gebruik de waarden van een gehele class in een andere class.
// LESS
.bordered {
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
#menu a {
color: #111;
.bordered;
}
.post a {
color: red;
.bordered;
}
/* Compiled CSS */
.bordered {
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
#menu a {
color: #111;
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
.post a {
color: red;
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
@hans2103
Sunday 21 April 13
@hans2103
parametric mixins
parameters verwerkt in mixins
// LESS
.rounded-corners (@radius: 5px) {
-webkit-border-radius: @radius;
-moz-border-radius: @radius;
-ms-border-radius: @radius;
-o-border-radius: @radius;
border-radius: @radius;
}
#header {
.rounded-corners;
}
#footer {
.rounded-corners(10px);
}
/* Compiled CSS */
#header {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
}
#footer {
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-ms-border-radius: 10px;
-o-border-radius: 10px;
border-radius: 10px;
}
@hans2103
Sunday 21 April 13
@hans2103
operations (simple mathematical operators: + - * / )
// LESS
.font-size(@font-size: 16){
@remValue: (@font-size / 10);
font-size: @font-size * 1px;
font-size: ~"@{remValue}rem";
}
html {
font-size: 62.5%;
}
body {
.font-size();
}
h1 {
.font-size(24);
}
/* Compiled CSS */
html {
font-size: 62.5%;
}
body {
font-size: 16px;
font-size: 1.6rem;
}
h1 {
font-size: 24px;
font-size: 2.4rem;
}
http://snook.ca/archives/html_and_css/font-size-with-rem
Sunday 21 April 13
@hans2103
operations (simple mathematical operators: + - * / )
// LESS
@the-border: 2px;
@base-color: #111;
#header {
color: (@base-color * 3);
border-top: (@the-border / 2);
border-right: (@the-border + 2);
border-bottom: (@the-border - 1);
border-left: @the-border;
}
#footer {
color: (@base-color + #003300);
}
/* Compiled CSS */
#header {
color: #333;
border-top: 1px;
border-right: 4px;
border-bottom: 1px;
border-left: 2px;
}
#footer {
color: #114411;
}
Sunday 21 April 13
@hans2103
// LESS
escape(@string); // URL encodes a string
e(@string); // escape string content
%(@string, values...); // formats a string
unit(@dimension, [@unit: ""]); // remove or change the unit of a dimension
color(@string); // parses a string to a color
data-uri([mimetype,] url); // * inlines a resource and falls back to url()
ceil(@number); // rounds up to an integer
floor(@number); // rounds down to an integer
percentage(@number); // converts to a %, e.g. 0.5 -> 50%
round(number, [places: 0]); // rounds a number to a number of places
sqrt(number); // * calculates square root of a number
abs(number); // * absolute value of a number
sin(number); // * sine function
asin(number); // * arcsine - inverse of sine function
cos(number); // * cosine function
acos(number); // * arccosine - inverse of cosine function
tan(number); // * tangent function
atan(number); // * arctangent - inverse of tangent function
functions (map one-to-one with Javascript code)
@hans2103
http://lesscss.org/#reference
Sunday 21 April 13
@hans2103
functions - darken & lighten
// LESS
.background_gradient(@base) {
background: @base;
background: -webkit-gradient(linear, left top, left bottom, from(lighten(@base, 5%)), to(darken
background: -moz-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%));
}
@orange_base: #f78d1d;
.orange { .background_gradient(@orange_base);
&:hover { .background_gradient(darken(@orange_base, 10%)); }
&:active { .background_gradient(lighten(@orange_base, 10%)); }
}
@blue_base: #7db8db;
.blue { .background_gradient(@blue_base);
&:hover { .background_gradient(darken(@blue_base, 10%)); }
&:active { .background_gradient(lighten(@blue_base, 10%)); }
}
@hans2103
http://lesscss.org/#reference
Sunday 21 April 13
@hans2103
functions - darken & lighten
/* Compiled CSS */
.orange {
background: #f78d1d;
background: -webkit-gradient(linear,left top,left bottom,from(#f89936),to(#f28009));
background: -moz-linear-gradient(top,#f89936,#f28009);
}
.orange:hover {
background: #d97308;
background: -webkit-gradient(linear,left top,left bottom,from(#f28009),to(#c16607));
background: -moz-linear-gradient(top,#f28009,#c16607);
}
.orange:active {
background: #f9a64e;
background: -webkit-gradient(linear,left top,left bottom,from(#fab267),to(#f89936));
background: -moz-linear-gradient(top,#fab267,#f89936);
}
.blue {
background: #7db8db;
background: -webkit-gradient(linear,left top,left bottom,from(#91c3e1),to(#69add5));
background: -moz-linear-gradient(top,#91c3e1,#69add5);
}
@hans2103
http://lesscss.org/#reference
Sunday 21 April 13
@hans2103
functions - escaping
// LESS
.background_gradient(@base) {
background-color: @base;
background-image: -webkit-gradient(linear, left top, left bottom, from(lighten(@base, 5%)), to(
background-image: -webkit-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%));
background-image: -moz-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%));
background-image: -o-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%));
background-image: linear-gradient(to bottom, lighten(@base, 5%), darken(@base, 5%));
filter: e(progid:DXImageTransform.Microsoft.gradient(startColorstr=lighten(@base, 5%), end
}
@orange_base: #f78d1d;
.orange { .background_gradient(@orange_base);
&:hover { .background_gradient(darken(@orange_base, 10%)); }
&:active { .background_gradient(lighten(@orange_base, 10%)); }
}
@blue_base: #7db8db;
.blue { .background_gradient(@blue_base);
&:hover { .background_gradient(darken(@blue_base, 10%)); }
&:active { .background_gradient(lighten(@blue_base, 10%)); }
}
@hans2103
http://lesscss.org/#reference
Sunday 21 April 13
@hans2103
functions - escaping
/* Compiled CSS */
.orange {
background-color: #f78d1d;
background-image: -webkit-gradient(linear,left top,left bottom,from(#f89936),to(#f28009));
background-image: -webkit-linear-gradient(top,#f89936,#f28009);
background-image: -moz-linear-gradient(top,#f89936,#f28009);
background-image: -o-linear-gradient(top,#f89936,#f28009);
background-image: linear-gradient(to bottom,#f89936,#f28009);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#f89936,endColorstr=#f28
}
.orange:hover {
background-color: #f78d1d;
background-image: -webkit-gradient(linear,left top,left bottom,from(#f28009),to(#c16607));
background-image: -webkit-linear-gradient(top,#f28009,#c16607);
background-image: -moz-linear-gradient(top,#f28009,#c16607);
background-image: -o-linear-gradient(top,#f28009,#c16607);
background-image: linear-gradient(to bottom,#f28009,#c16607);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#f28009,endColorstr=#c16
}
.orange:active {
background-color: #f9a64e;
@hans2103
http://lesscss.org/#reference
Sunday 21 April 13
@hans2103
functions - data-uri
// LESS
data-uri('image/jpeg;base64', '../data/image.jpg');
/* Compiled CSS */
url('data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg==');
@hans2103
http://lesscss.org/#reference
flinke reductie HTTP-request.
voor- en nadelen beschreven in wiki
http://en.wikipedia.org/wiki/
Data_URI_scheme#Advantages
Sunday 21 April 13
@hans2103
String interpolation
// LESS
@baseUrl: "http://joomladagen.nl/";
@imageUrl: "images/";
background-image: url('@{baseUrl}@{imageUrl}logo.png');
/* CSS Compilation */
background-image: url('http://joomladagen.nl/images/logo.png');
@hans2103
http://lesscss.org/#reference
Sunday 21 April 13
@hans2103
scope
// LESS
header {
	

 @color: black;
	

 background-color: @color;
	

 nav {
	

 	

 @color: blue;
	

 	

 background-color: @color;
	

 	

 a {
	

 	

 color: @color;
	

 	

 }
	

 }
	

 h1 {
	

 	

 color: @color;
	

 }
}
@hans2103
/* Compiled CSS */
header {
background-color: black;
}
header nav {
background-color: blue;
}
header nav a {
color: blue;
}
header h1 {
color: black;
}
Sunday 21 April 13
@hans2103
combinator
Gebruik de waarden van een gehele class in een andere class.
// LESS
.bordered, .rounded {
&.float {
float: left;
}
.top {
margin: 5px;
}
& + & {
color: yellow;
}
}
/* Compiled CSS */
.bordered.float,
.rounded.float {
float: left;
}
.bordered .top,
.rounded .top {
margin: 5px;
}
.bordered + .bordered,
.rounded + .rounded {
color: yellow;
}
@hans2103
Sunday 21 April 13
@hans2103@hans2103
http://leafo.net/lessphp/lessify/
Sunday 21 April 13
@hans2103@hans2103
http://leafo.net/lessphp/editor.html
Sunday 21 April 13
@hans2103@hans2103
Sunday 21 April 13
@hans2103@hans2103
Sunday 21 April 13
@hans2103@hans2103
Sunday 21 April 13
@hans2103@hans2103
Sunday 21 April 13
@hans2103@hans2103
Sunday 21 April 13
@hans2103
Hopsakee...
aan de slag!
gewoon beginnen
Sunday 21 April 13
@hans2103
veel plezier
Sunday 21 April 13
@hans2103
http://www.flickr.com/photos/trasimac/1217071176
thank you for your time and have fun
http://slideshare.net/hans2103
hans2103
http://about.me/hans2103
Sunday 21 April 13

Weitere ähnliche Inhalte

Was ist angesagt?

Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
Wynn Netherland
 

Was ist angesagt? (13)

CSS Frameworks
CSS FrameworksCSS Frameworks
CSS Frameworks
 
جيفيرا باي الساحل الشمالي
جيفيرا باي الساحل الشماليجيفيرا باي الساحل الشمالي
جيفيرا باي الساحل الشمالي
 
Theme Kickstart
Theme KickstartTheme Kickstart
Theme Kickstart
 
FoundConf 2018 Signals Speak - Alexis Sanders
FoundConf 2018 Signals Speak - Alexis SandersFoundConf 2018 Signals Speak - Alexis Sanders
FoundConf 2018 Signals Speak - Alexis Sanders
 
Theme02
Theme02Theme02
Theme02
 
Accelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gemAccelerated Native Mobile Development with the Ti gem
Accelerated Native Mobile Development with the Ti gem
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Haml And Sass
Haml And SassHaml And Sass
Haml And Sass
 
Sass maps, my precious! 2.0
Sass maps, my precious! 2.0Sass maps, my precious! 2.0
Sass maps, my precious! 2.0
 
Theme01
Theme01Theme01
Theme01
 
Theme03
Theme03Theme03
Theme03
 
Layout with CSS
Layout with CSSLayout with CSS
Layout with CSS
 
Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 

Ähnlich wie CSS with LESS for #jd13nl

SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
Itai Koren
 
LESS is More
LESS is MoreLESS is More
LESS is More
jsmith92
 
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
Dinu Suman
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Kaelig Deloumeau-Prigent
 

Ähnlich wie CSS with LESS for #jd13nl (20)

Css frameworks
Css frameworksCss frameworks
Css frameworks
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
Less css
Less cssLess css
Less css
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
Doing more with LESS
Doing more with LESSDoing more with LESS
Doing more with LESS
 
LESS is More
LESS is MoreLESS is More
LESS is More
 
Preprocessor presentation
Preprocessor presentationPreprocessor presentation
Preprocessor presentation
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
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
 
Wrangling the CSS Beast with Sass
Wrangling the CSS Beast  with SassWrangling the CSS Beast  with Sass
Wrangling the CSS Beast with Sass
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
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
 
LESS
LESSLESS
LESS
 
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
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
Learn Sass and Compass quick
Learn Sass and Compass quickLearn Sass and Compass quick
Learn Sass and Compass quick
 
Why less?
Why less?Why less?
Why less?
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
Doing More With Less
Doing More With LessDoing More With Less
Doing More With Less
 
FCIP SASS Talk
FCIP SASS TalkFCIP SASS Talk
FCIP SASS Talk
 

Mehr von Hans Kuijpers

Mehr von Hans Kuijpers (20)

JD19NL - Joomla Template Overrides, Alternate Layouts en JLayouts
JD19NL - Joomla Template Overrides, Alternate Layouts en JLayoutsJD19NL - Joomla Template Overrides, Alternate Layouts en JLayouts
JD19NL - Joomla Template Overrides, Alternate Layouts en JLayouts
 
RSForm!pro jug073 maart 2019
RSForm!pro  jug073 maart 2019RSForm!pro  jug073 maart 2019
RSForm!pro jug073 maart 2019
 
Template overrides in joomla jug073 februari 2019
Template overrides in joomla   jug073 februari 2019Template overrides in joomla   jug073 februari 2019
Template overrides in joomla jug073 februari 2019
 
Joomla Website optimaliseren - jug073 augustus 2018
Joomla Website optimaliseren - jug073 augustus 2018Joomla Website optimaliseren - jug073 augustus 2018
Joomla Website optimaliseren - jug073 augustus 2018
 
Joomla Custom Fields - the next level
Joomla Custom Fields - the next level Joomla Custom Fields - the next level
Joomla Custom Fields - the next level
 
Best Practice: Joomla! templating
Best Practice: Joomla! templatingBest Practice: Joomla! templating
Best Practice: Joomla! templating
 
JD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layoutsJD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layouts
 
Maak je website geschikt voor mobiel
Maak je website geschikt voor mobielMaak je website geschikt voor mobiel
Maak je website geschikt voor mobiel
 
Bootstrap 3 in Joomla!
Bootstrap 3 in Joomla!Bootstrap 3 in Joomla!
Bootstrap 3 in Joomla!
 
Google Webmasters Tools
Google Webmasters ToolsGoogle Webmasters Tools
Google Webmasters Tools
 
Google Tag Manager #jd14nl
Google Tag Manager #jd14nlGoogle Tag Manager #jd14nl
Google Tag Manager #jd14nl
 
Social Share Buttons - #jd14nl
Social Share Buttons - #jd14nlSocial Share Buttons - #jd14nl
Social Share Buttons - #jd14nl
 
Site Performance Optimization for Joomla #jwc13
Site Performance Optimization for Joomla #jwc13Site Performance Optimization for Joomla #jwc13
Site Performance Optimization for Joomla #jwc13
 
Rich Snippets in Joomla - #JUG073
Rich Snippets in Joomla - #JUG073Rich Snippets in Joomla - #JUG073
Rich Snippets in Joomla - #JUG073
 
Rich Snippets in Magento product page - #MUG020
Rich Snippets in Magento product page - #MUG020Rich Snippets in Magento product page - #MUG020
Rich Snippets in Magento product page - #MUG020
 
Rich Snippets in Magento product page
Rich Snippets in Magento product pageRich Snippets in Magento product page
Rich Snippets in Magento product page
 
Site Speed Optimisation for JWC2012
Site Speed Optimisation for JWC2012Site Speed Optimisation for JWC2012
Site Speed Optimisation for JWC2012
 
Form2content case for #JUG073
Form2content case for #JUG073Form2content case for #JUG073
Form2content case for #JUG073
 
Magento Theme - set the basics right - mm12nl
Magento Theme - set the basics right - mm12nlMagento Theme - set the basics right - mm12nl
Magento Theme - set the basics right - mm12nl
 
Google analytics - jd12nl met Byte Internet
Google analytics - jd12nl met Byte InternetGoogle analytics - jd12nl met Byte Internet
Google analytics - jd12nl met Byte Internet
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
+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...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
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, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

CSS with LESS for #jd13nl

  • 1. @hans2103 CSS met LESS waar begin ik? een presentatie voor de Joomla!dagen 21 april 2013 Woudschoten - Zeist hans2103 Sunday 21 April 13
  • 2. @hans2103 CSS met LESS waar begin ik? een presentatie voor de Joomla!dagen 21 april 2013 Woudschoten - Zeist hans2103 presentatie kun je downloaden via http://slideshare.net/hans2103 Sunday 21 April 13
  • 3. @hans2103 Wat is LESS? • LESS is een programmeertaal • LESS compileer je naar CSS • LESS is een CSS preprocessor • LESS syntax is gemaakt vanuit CSS • LESS is dynamisch CSS Sunday 21 April 13
  • 4. @hans2103 Waarom LESS gebruiken • LESS bespaart tijd • LESS vermindert fouten • LESS vermindert herhalingen • LESS is handig Sunday 21 April 13
  • 5. @hans2103 Hopsakee... aan de slag! veel code Sunday 21 April 13
  • 6. @hans2103 vooraf compileren on the fly compileren <link rel="stylesheet/css" href="style.css" /> <link rel="stylesheet/less" href="style.less" /> <script src="less.js"></script> Sunday 21 April 13
  • 7. @hans2103 style.less // LESS // import normalize for CSS resets @import "normalize"; // same as @import “normalize.less”; // import mixins @import "mixins"; // base for mobile devices @import "base"; //tables and small laptops @media only screen and (min-width: 768px) { @import "768up"; } //desktop @media only screen and (min-width: 1030px) { @import "1030up"; } Sunday 21 April 13
  • 9. @hans2103 clean structure with nesting /* Compiled CSS */ #header {} #header #nav {} #header #nav ul {} #header #nav ul li {} #header #nav ul li a {} // LESS # header { #nav { ul { li { a {} } } } } lijkt warempel op de HTML structuur Sunday 21 April 13
  • 10. @hans2103 clean structure with nesting /* Compiled CSS */ a {} a:hover {} a:active {} a:visited {} // LESS a { &:hover {} &:active {} &:visited {} } Sunday 21 April 13
  • 11. @hans2103 variables standaard waarden om te hergebruiken in de stylesheet. // LESS @color: #4D926F; @serif: serif; @sans-serif: sans-serif; #header { color: @color; font-family: @serif; } h2 { color: @color; font-family: @sans-serif; } /* Compiled CSS */ #header { color: #4D926F; font-family: serif; } h2 { color: #4D926F; font-family: sans-serif; } Sunday 21 April 13
  • 12. @hans2103 mixins Gebruik de waarden van een gehele class in een andere class. // LESS .bordered { border-top: dotted 1px black; border-bottom: solid 2px black; } #menu a { color: #111; .bordered; } .post a { color: red; .bordered; } /* Compiled CSS */ .bordered { border-top: dotted 1px black; border-bottom: solid 2px black; } #menu a { color: #111; border-top: dotted 1px black; border-bottom: solid 2px black; } .post a { color: red; border-top: dotted 1px black; border-bottom: solid 2px black; } @hans2103 Sunday 21 April 13
  • 13. @hans2103 parametric mixins parameters verwerkt in mixins // LESS .rounded-corners (@radius: 5px) { -webkit-border-radius: @radius; -moz-border-radius: @radius; -ms-border-radius: @radius; -o-border-radius: @radius; border-radius: @radius; } #header { .rounded-corners; } #footer { .rounded-corners(10px); } /* Compiled CSS */ #header { -webkit-border-radius: 5px; -moz-border-radius: 5px; -ms-border-radius: 5px; -o-border-radius: 5px; border-radius: 5px; } #footer { -webkit-border-radius: 10px; -moz-border-radius: 10px; -ms-border-radius: 10px; -o-border-radius: 10px; border-radius: 10px; } @hans2103 Sunday 21 April 13
  • 14. @hans2103 operations (simple mathematical operators: + - * / ) // LESS .font-size(@font-size: 16){ @remValue: (@font-size / 10); font-size: @font-size * 1px; font-size: ~"@{remValue}rem"; } html { font-size: 62.5%; } body { .font-size(); } h1 { .font-size(24); } /* Compiled CSS */ html { font-size: 62.5%; } body { font-size: 16px; font-size: 1.6rem; } h1 { font-size: 24px; font-size: 2.4rem; } http://snook.ca/archives/html_and_css/font-size-with-rem Sunday 21 April 13
  • 15. @hans2103 operations (simple mathematical operators: + - * / ) // LESS @the-border: 2px; @base-color: #111; #header { color: (@base-color * 3); border-top: (@the-border / 2); border-right: (@the-border + 2); border-bottom: (@the-border - 1); border-left: @the-border; } #footer { color: (@base-color + #003300); } /* Compiled CSS */ #header { color: #333; border-top: 1px; border-right: 4px; border-bottom: 1px; border-left: 2px; } #footer { color: #114411; } Sunday 21 April 13
  • 16. @hans2103 // LESS escape(@string); // URL encodes a string e(@string); // escape string content %(@string, values...); // formats a string unit(@dimension, [@unit: ""]); // remove or change the unit of a dimension color(@string); // parses a string to a color data-uri([mimetype,] url); // * inlines a resource and falls back to url() ceil(@number); // rounds up to an integer floor(@number); // rounds down to an integer percentage(@number); // converts to a %, e.g. 0.5 -> 50% round(number, [places: 0]); // rounds a number to a number of places sqrt(number); // * calculates square root of a number abs(number); // * absolute value of a number sin(number); // * sine function asin(number); // * arcsine - inverse of sine function cos(number); // * cosine function acos(number); // * arccosine - inverse of cosine function tan(number); // * tangent function atan(number); // * arctangent - inverse of tangent function functions (map one-to-one with Javascript code) @hans2103 http://lesscss.org/#reference Sunday 21 April 13
  • 17. @hans2103 functions - darken & lighten // LESS .background_gradient(@base) { background: @base; background: -webkit-gradient(linear, left top, left bottom, from(lighten(@base, 5%)), to(darken background: -moz-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%)); } @orange_base: #f78d1d; .orange { .background_gradient(@orange_base); &:hover { .background_gradient(darken(@orange_base, 10%)); } &:active { .background_gradient(lighten(@orange_base, 10%)); } } @blue_base: #7db8db; .blue { .background_gradient(@blue_base); &:hover { .background_gradient(darken(@blue_base, 10%)); } &:active { .background_gradient(lighten(@blue_base, 10%)); } } @hans2103 http://lesscss.org/#reference Sunday 21 April 13
  • 18. @hans2103 functions - darken & lighten /* Compiled CSS */ .orange { background: #f78d1d; background: -webkit-gradient(linear,left top,left bottom,from(#f89936),to(#f28009)); background: -moz-linear-gradient(top,#f89936,#f28009); } .orange:hover { background: #d97308; background: -webkit-gradient(linear,left top,left bottom,from(#f28009),to(#c16607)); background: -moz-linear-gradient(top,#f28009,#c16607); } .orange:active { background: #f9a64e; background: -webkit-gradient(linear,left top,left bottom,from(#fab267),to(#f89936)); background: -moz-linear-gradient(top,#fab267,#f89936); } .blue { background: #7db8db; background: -webkit-gradient(linear,left top,left bottom,from(#91c3e1),to(#69add5)); background: -moz-linear-gradient(top,#91c3e1,#69add5); } @hans2103 http://lesscss.org/#reference Sunday 21 April 13
  • 19. @hans2103 functions - escaping // LESS .background_gradient(@base) { background-color: @base; background-image: -webkit-gradient(linear, left top, left bottom, from(lighten(@base, 5%)), to( background-image: -webkit-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%)); background-image: -moz-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%)); background-image: -o-linear-gradient(top, lighten(@base, 5%), darken(@base, 5%)); background-image: linear-gradient(to bottom, lighten(@base, 5%), darken(@base, 5%)); filter: e(progid:DXImageTransform.Microsoft.gradient(startColorstr=lighten(@base, 5%), end } @orange_base: #f78d1d; .orange { .background_gradient(@orange_base); &:hover { .background_gradient(darken(@orange_base, 10%)); } &:active { .background_gradient(lighten(@orange_base, 10%)); } } @blue_base: #7db8db; .blue { .background_gradient(@blue_base); &:hover { .background_gradient(darken(@blue_base, 10%)); } &:active { .background_gradient(lighten(@blue_base, 10%)); } } @hans2103 http://lesscss.org/#reference Sunday 21 April 13
  • 20. @hans2103 functions - escaping /* Compiled CSS */ .orange { background-color: #f78d1d; background-image: -webkit-gradient(linear,left top,left bottom,from(#f89936),to(#f28009)); background-image: -webkit-linear-gradient(top,#f89936,#f28009); background-image: -moz-linear-gradient(top,#f89936,#f28009); background-image: -o-linear-gradient(top,#f89936,#f28009); background-image: linear-gradient(to bottom,#f89936,#f28009); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#f89936,endColorstr=#f28 } .orange:hover { background-color: #f78d1d; background-image: -webkit-gradient(linear,left top,left bottom,from(#f28009),to(#c16607)); background-image: -webkit-linear-gradient(top,#f28009,#c16607); background-image: -moz-linear-gradient(top,#f28009,#c16607); background-image: -o-linear-gradient(top,#f28009,#c16607); background-image: linear-gradient(to bottom,#f28009,#c16607); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#f28009,endColorstr=#c16 } .orange:active { background-color: #f9a64e; @hans2103 http://lesscss.org/#reference Sunday 21 April 13
  • 21. @hans2103 functions - data-uri // LESS data-uri('image/jpeg;base64', '../data/image.jpg'); /* Compiled CSS */ url('data:image/jpeg;base64,bm90IGFjdHVhbGx5IGEganBlZyBmaWxlCg=='); @hans2103 http://lesscss.org/#reference flinke reductie HTTP-request. voor- en nadelen beschreven in wiki http://en.wikipedia.org/wiki/ Data_URI_scheme#Advantages Sunday 21 April 13
  • 22. @hans2103 String interpolation // LESS @baseUrl: "http://joomladagen.nl/"; @imageUrl: "images/"; background-image: url('@{baseUrl}@{imageUrl}logo.png'); /* CSS Compilation */ background-image: url('http://joomladagen.nl/images/logo.png'); @hans2103 http://lesscss.org/#reference Sunday 21 April 13
  • 23. @hans2103 scope // LESS header { @color: black; background-color: @color; nav { @color: blue; background-color: @color; a { color: @color; } } h1 { color: @color; } } @hans2103 /* Compiled CSS */ header { background-color: black; } header nav { background-color: blue; } header nav a { color: blue; } header h1 { color: black; } Sunday 21 April 13
  • 24. @hans2103 combinator Gebruik de waarden van een gehele class in een andere class. // LESS .bordered, .rounded { &.float { float: left; } .top { margin: 5px; } & + & { color: yellow; } } /* Compiled CSS */ .bordered.float, .rounded.float { float: left; } .bordered .top, .rounded .top { margin: 5px; } .bordered + .bordered, .rounded + .rounded { color: yellow; } @hans2103 Sunday 21 April 13
  • 32. @hans2103 Hopsakee... aan de slag! gewoon beginnen Sunday 21 April 13
  • 34. @hans2103 http://www.flickr.com/photos/trasimac/1217071176 thank you for your time and have fun http://slideshare.net/hans2103 hans2103 http://about.me/hans2103 Sunday 21 April 13