I. Overview
Less is a CSS preprocessing language, it extends the CSS language, adding variables, mixin, functions and other features, so that the CSS easier to maintain and expand.
Less can run on Node or browser side
second, less environment to build
Less can be used on the server or client side
1. Use at service end:
Install the less compilation tool: NPM install Less-g
After you install less, you can call the less compiler on the command line, as follows:
LESSC styles.less
This will output the compiled CSS code to stdout, and you can redirect the output to a file:
$ LESSC styles.less > Styles.css
To output a compressed CSS, simply add the-x option. If you want a better compression effect, you can also enable clean CSS for compression with the –CLEAN-CSS option.
Executes LESSC with no arguments and prints a list of all available options on the command line
Use less in idea (you need to install the file Watchers plugin)
2. Clients use less:
Using Less.js on the client is the easiest way to do it, and it is convenient in the development phase, but in a production environment, performance and reliability are important, and it is recommended that you use Node.js or other third-party tools for precompiling.
Add a link to the. Less style sheet in the page and set the Rel property to "stylesheet/less":
<link rel= "stylesheet/less" type= "Text/css" href= "styles.less"/>
Next, download the less.js and introduce it through the tag, placed in the element of the page:
<script src= "Less.js" type= "Text/javascript" ></script>
3. Use of less in sublime:
First you need to install LESS:NPM install-g less
You also need to install a less plugin for compressing CSS files: npm install-g less-plugin-clean-css
Then install the sublime plugin (ctrl+shift+p>install Package): syntax highlighting plug-in: less less file compilation plug-in: Less2css