on the advantages and disadvantages of less language
Advantages:
- The structure is clear and easy to expand. For many of the modules of the application, especially the single-page app, often need to use selector to divide the CSS of different modules scope. If you look at all. module. Action. List A,. module. Action. List A:hover It is difficult to intuitively understand the scope of the style application;
. module {
. Action {
A, a:hover {
Styles
}
}
}
Other modules
This is much clearer. This maintainability is bound to be much higher, for example: If you want to change the application scope of the style, add a suitable action, just change the. Action to. Action,. Action2, and pure CSS is tragic, to modify the selector of each relevant rule set.
- It is easy to block browser private syntax differences. This needless to say, the package of browser syntax differences in the repetition of processing, reduce meaningless mechanical labor.
- Multiple inheritance can be easily implemented.
. box {
Display:block;
}
. thick-bordered {
border:5px solid black;
}
. notice {
. Box;
. thick-bordered;
}
This way, the subclass will synchronize updates regardless of any changes to the parent class. Some people say that it's good to write the class as "notice box thick-bordered" in HTML, but this increases the coupling between HTML and style, if there are more than one in the template. Notice will inevitably do repetitive work when modified, and in addition to the modified CSS file, The client-side cached HTML template also needs to be downloaded again. In less, if mixin is used for inheritance, there is no need to generate a useless parent style code after compilation.
- Fully compatible with CSS code, can be easily applied to the old project. Less just expands on CSS syntax, so old CSS code can also be compiled with less code.
Disadvantages:
1, need to compile. This is an additional expense, whether on the client or the server side.
- Gu Yiling
Links: https://www.zhihu.com/question/20259365/answer/14520148
On the advantages and disadvantages of less language