Introduction ----
css (cascading style sheets) is a long-standing, markup language that joins HTML is widely used in the World Wide Web. HTML is primarily responsible for the definition of document structure, and CSS is responsible for the definition of document representation or style.
principle ----
Less can be used directly on the client or on the server side. In the actual project development, we recommend using the third method, compile the less file to build a static CSS file, and apply it in the HTML document.
Client
we can use the. Less source file directly on the client, just from http://lesscss.org Download the Less.js file and add the following code to the HTML that we need to introduce the less source file:
<link rel= "stylesheet/less" type= "Text/css" href= "styles.less" >
Less source files are introduced in the same way that standard CSS files are introduced:
<link rel= "stylesheet/less" type= "Text/css" href= "styles.less" >
It is important to note that the Rel attribute is set to "Stylesheet/less" when the. less file is introduced. A more important point to note is that the less source file must be introduced before Less.js is introduced, so as to ensure that less source files are correctly compiled and parsed.
Server-Side
less on the server side is mainly the help of the less compiler, the less source file compilation to generate the final CSS file, the current common way is to use node's Package Manager (NPM) to install less, after successful installation can be in the node environment for the less source files compiled.
In the early stages of project development, we need to find ways to introduce our CSS or less files to our HTML pages or bridge files, regardless of whether we use the client or server side, less provides a feature-importing that we are familiar with. We can use this keyword to introduce the. less or. css file that we need. Such as:
@import "Variables.less";
The. Less file can also omit the suffix name, like this:
@import "Variables";
The introduction of CSS is just like the less file, except that the. css suffix name cannot be omitted.
-------------------------------------less tocompile based on node under Windows -----------------------------------
Install node (operation can refer to here http://www.cnblogs.com/pigtail/archive/2013/01/08/2850486.html)
Install less with NPM (NPM install less-g)
In the directory node. js COMMD prompt, switch to the filename.less file directory that you want to compile, enter the instructions LESSC test.less > Test.css
If successful, there will be a compiled test.less in the teset.less corresponding directory.
Less is compiled under Windows less