Less, lesscss

Source: Internet
Author: User

Less, lesscss

1 use @ to define the variable 2 and perform operations 3 4 @ color: #000; 5 @ width: 1000px; 6 7 use & to indicate the current Class 8. box {9 &: hover {10 color: #000; 11} 12} 13 14 css can be nested with 15 16 ul {17 display: block; 18 li {19 float: left; 20 a {21 font-size: 18px; 22} 23} 24} 25 26 inheritance: reference the class or id class directly as needed 27 28. clearfix {29 zoom: 1; 30 display: block; 31 &: after {32 content: ""; 33 visibility: hidden; 34 clear: both; 35 height: 0; 36 display: block; 37} 38} 39 40. radius (@ radius: 15px) {41 border-radius: @ radius; 42} 43 44. box {45. clearfix; 46. radius (10px); 47} 48 49 mix: similar to functions in js, [or inheritance] 50. layout () {51... 52} 53 54 55 scope: limits the conditions for inheritance. It can inherit part of a class. 56 57 Extension: &: extend (. box ); you can enter multiple class names in the brackets. After compilation, the result is that the css group 58 59 60 when is used for condition determination. 61 62 when not equal to 63 64/* 65 use isnumber to judge a certain whether the parameter is Numeric 66 **/67 68. border (@ width: 1px, @ style: solid, @ color: # d1d1d1) when (isnumber (@ width) {69 border: @ width @ style @ color; 70} 71 72/* 73 use iscolor to determine whether a parameter is of a color 74 **/75 76. border (@ color) when (iscolor (@ color) {77 78. border (1px, solid, @ color); 79} 80 81 82. border (@ solid) when not (iscolor (@ solid), (isnumber (@ solid) {83. border (1px, @ solid); 84}

 

Use @ to define variable variables for calculation @ color: #000; @ width: 1000px; Use & to indicate the current class. box {&: hover {color: #000 ;}}
Css nesting
Ul {display: block; li {float: left; a {font-size: 18px ;}}}
Inheritance: class or id class is referenced directly as needed.
. Clearfix {zoom: 1; display: block; &: after {content: ""; visibility: hidden; clear: both; height: 0; display: block ;}}
. Radius (@ radius: 15px) {border-radius: @ radius ;}
. Box {. clearfix;. radius (10px );}
HYBRID: similar to functions in js, [or called inheritance]. layout (){...}

Scope: limits the conditions for inheritance. It can inherit part of the content of a class.
Extension: &: extend (. box); you can enter multiple class names in brackets. After compilation, the effect is the grouping in css.

When is used for condition determination.
When not equal
/* Use isnumber to determine whether a parameter is a number **/
. Border (@ width: 1px, @ style: solid, @ color: # d1d1d1) when (isnumber (@ width) {border: @ width @ style @ color ;}
/* Use iscolor to determine whether a parameter is color **/
. Border (@ color) when (iscolor (@ color) {. border (1px, solid, @ color );}

. Border (@ solid) when not (iscolor (@ solid), (isnumber (@ solid) {. border (1px, @ solid );}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.