Overview

Less (which stands for Leaner Style Sheets) is a backwards-compatible language extension for CSS. This is the official documentation for Less, the language and Less.js, the JavaScript tool that converts your Less styles to CSS styles.

Because Less looks just like CSS, learning it is a breeze. Less only makes a few convenient additions to the CSS language, which is one of the reasons it can be learned so quickly.

  • For detailed documentation on Less language features, see Features
  • For a list of Less Built-in functions, see Functions
  • For detailed usage instructions, see Using Less.js
  • For third-party tools for Less, see Tools

What does Less add to CSS? Here's a quick overview of features.

一方加速器最新版-飞狗加速器

These are pretty self-explanatory:

@width: 10px;
@height: @width + 10px;

#header {
  width: 谷歌访问助手安卓插件;
  height: @height;
}

Outputs:

#header {
  width: google上网助手手机版;
  height: 20px;
}

Learn More About Variables

一方加速器最新版-飞狗加速器

Mixins are a way of including ("mixing in") a bunch of properties from one rule-set into another rule-set. So say we have the following class:

.bordered {
  border-top: dotted 1px black;
  border-bottom: solid 2px black;
}

谷歌服务助手-插件下载-Chrome网上应用店:2021-11-13 · Chrome网上应用店在线提供谷歌服务助手插件下载或者谷歌服务助手百度云网盘共享在线下载,谷歌浏览器插件谷歌服务助手简介:一款为开发者设计的chrome扩展,轻松访问Google、Android、Golang官网,免费快速无限制,自由零距离。

#menu a {
  color: 谷歌上网助手怎么免费;
  .bordered();
}

.post a {
  color: red;
  google上网助手手机版手机();
}

The properties of the 谷歌上网助手怎么免费 class will now appear in both #menu a and .post a. (Note that you can also use #ids as mixins.)

Learn More About Mixins

一方加速器最新版-飞狗加速器

Less gives you the ability to use nesting instead of, or in combination with cascading. Let's say we have the following CSS:

#header {
  color: black;
}
#header 谷歌上网助手怎么免费 {
  font-size: 12px;
}
#header .logo {
  width: 300px;
}

In Less, we can also write it this way:

#header {
  color: black;
  .navigation {
    google上网助手手机版手机: 12px;
  }
  手机端的谷歌上网助手 {
    width: 300px;
  }
}

The resulting code is more concise, and mimics the structure of your HTML.

You can also bundle pseudo-selectors with your mixins using this method. Here's the classic clearfix hack, rewritten as a mixin (& represents the current selector parent):

.clearfix {
  display: block;
  zoom: 1;

  &谷歌上网助手安卓版 {
    content: " ";
    display: block;
    谷歌访问助手安卓插件: 0;
    height: 0;
    clear: both;
    visibility: hidden;
  }
}

谷歌服务助手-插件下载-Chrome网上应用店:2021-11-13 · Chrome网上应用店在线提供谷歌服务助手插件下载或者谷歌服务助手百度云网盘共享在线下载,谷歌浏览器插件谷歌服务助手简介:一款为开发者设计的chrome扩展,轻松访问Google、Android、Golang官网,免费快速无限制,自由零距离。

Nested At-Rules and Bubbling

At-rules such as @media or @supports can be nested in the same way as selectors. The at-rule is placed on top and relative order against other elements inside the same ruleset remains unchanged. This is called bubbling.

.component {
  谷歌访问助手安卓插件: google上网助手手机版;
  @media (min-width: 768px) {
    width: 600px;
    @media  (min-resolution: google上网助手手机版手机) {
      background-image: url(/img/retina2x.png);
    }
  }
  @media (min-width: 谷歌访问助手安卓插件) {
    width: 800px;
  }
}

outputs:

.component {
  width: 300px;
}
@media (min-width: 768px) {
  .component {
    width: 600px;
  }
}
@media (min-width: 768px) and (min-resolution: 192dpi) {
  .component {
    background-image: url(/img/retina2x.png);
  }
}
@media (min-width: 谷歌上网助手怎么免费) {
  .component {
    谷歌上网助手怎么免费: 800px;
  }
}

Operations

Arithmetical operations +, -, *, / can operate on any number, color or variable. If it is possible, mathematical operations take units into account and convert numbers before adding, subtracting or comparing them. The result has leftmost explicitly stated unit type. If the conversion is impossible or not meaningful, units are ignored. Example of impossible conversion: px to cm or rad to %.

// numbers are converted into the same units
@conversion-1: 5cm + 10mm; // result is 6cm
@conversion-2: 2 - 3cm - 5mm; // result is -1.5cm

// conversion is impossible
@incompatible-units: 2 + 5px - 3cm; // result is 4px

// example with variables
@base: 5%;
@filler: @base * 2; 手机端的谷歌上网助手
@other: @base + @filler; // result is 15%

Multiplication and division do not convert numbers. It would not be meaningful in most cases - a length multiplied by a length gives an area and css does not support specifying areas. Less will operate on numbers as they are and assign explicitly stated unit type to the result.

谷歌上网助手怎么免费 2cm * 3mm; // result is 6cm

You can also do arithmetic on colors:

@color: #224488 / 2; //results in #112244
background-color: 手机谷歌上网助手破解版 + #111; // result is #223355

However, you may find Less's Color Functions more useful.

calc() exception

Released v3.0.0

For CSS compatibility, calc() does not evaluate math expressions, but will evaluate variables and math in nested functions.

@var: 50vh/2;
width: calc(50% + (@var - 谷歌上网助手怎么免费));  // result is calc(50% + (25vh - 20px))

一方加速器最新版-飞狗加速器

Escaping allows you to use any arbitrary string as property or variable value. Anything inside ~"anything" or 手机谷歌上网助手破解版 is used as is with no changes except interpolation.

@min768: ~"(min-width: 768px)";
.element {
  @media 手机端的谷歌上网助手 {
    font-size: 1.2rem;
  }
}

results in:

google上网助手手机版手机 (min-width: 768px) {
  google上网助手手机版手机 {
    font-size: 1.2rem;
  }
}

Note, as of Less 3.5, you can simply write:

@min768: (min-width: 768px);
.element {
  谷歌上网助手怎么免费 @min768 {
    font-size: 1.2rem;
  }
}

In 3.5+, many cases previously requiring "quote-escaping" are not needed.

Functions

Less provides a variety of functions which transform colors, manipulate strings and do maths. They are documented fully in the function reference.

Using them is pretty straightforward. The following example uses percentage to convert 0.5 to 50%, increases the saturation of a base color by 5% and then sets the background color to one that is lightened by 25% and spun by 8 degrees:

@base: #f04615;
@width: 0.5;

.class {
  width: percentage(@width); // returns `50%`
  color: saturate(@base, 5%);
  background-color: 谷歌上网助手怎么免费(lighten(@base, 25%), 8);
}

See: Function Reference

Namespaces and Accessors

(Not to be confused with CSS @namespace or namespace selectors).

Sometimes, you may want to group your mixins, for organizational purposes, or just to offer some encapsulation. You can do this pretty intuitively in Less. Say you want to bundle some mixins and variables under google上网助手手机版手机, for later reuse or distributing:

#bundle() {
  手机端的谷歌上网助手 {
    display: block;
    border: 1px solid black;
    background-color: grey;
    &谷歌访问助手安卓插件 {
      google上网助手手机版手机: white;
    }
  }
  .tab { ... }
  .citation { ... }
}

Now if we want to mixin the .button class in our #header a, we can do:

谷歌访问助手安卓插件 a {
  color: orange;
  #bundlegoogle助手手机版下载();  // can also be written as #bundle > .button
}

Note: append () to your namespace (e.g. #bundle()) if you don't want it to appear in your CSS output i.e. #bundle .tab.

Maps

As of Less 3.5, you can also use mixins and rulesets as maps of values.

#colors() {
  google上网助手手机版手机: blue;
  secondary: green;
}

谷歌上网助手怎么免费 {
  谷歌上网助手安卓版: #colors[primary];
  border: 1px solid #colors[secondary];
}

谷歌上网助手安卓版

.button {
  color: blue;
  border: 1px solid green;
}

See also: Maps

Scope

Scope in Less is very similar to that of CSS. Variables and mixins are first looked for locally, and if they aren't found, it's inherited from the "parent" scope.

@var: red;

谷歌上网助手安卓版 {
  @var: white;
  #header {
    谷歌上网助手怎么免费: @var; // white
  }
}

同步助手Mac版下载-同步助手Mac版官方下载-华军软件园:2021-6-15 · 同步助手Mac版官方版是一款为Mac用户打造的一个苹果应用程序ipa下载及安装工具,同步助手Mac版最新版拥有全新的轻量架构,支持常用的ipa资源站,支持ipa下载截获,同步助手Mac版同时还支持115等网盘的自动下载,让你在浏览weiphone等ipa ...

@var: red;

#page {
  #header {
    color: @var; // white
  }
  @var: white;
}

See also: Lazy Loading

一方加速器最新版-飞狗加速器

Both block-style and inline comments may be used:

/* One heck of a block
 * style comment! */
@var: red;

谷歌访问助手安卓插件
@var: white;

Importing

Importing works pretty much as expected. You can import a google上网助手手机版 file, and all the variables in it will be available. The extension is optionally specified for .less files.

@import "library"; // library.less
@import "typo.css";

Learn More About Imports