In the Bootstrap grid system (source code) There is this paragraph,
[class*= "Span"] { float:left; Margin-left: @gridGutterWidth;}
To run with recess, you'll see a hint:
Universal selectors should be avoided
。 This can be said to be a selector problem, but also can be said to be a recess problem, but can be run at the time of adding a parameter ignored.
When you write the extension yourself, you will write similar rules, such as the need to be compatible with a browser, if not, you will need to write like Bootstrap-ie6
. Span1,. span2,. Span3,. Span4,. Span5,. Span6,.span7,. Span8,. Span9,. Span10,. Span11,. span12 { float:left; Display:inline;}
But this is too ugly and inflexible, and can not stand the change, when I use 16 grid or other non-12 grid, it is very passive.
If [Attr*=val] is not used, it is not known if less has something ready to simplify. I'm assuming there will be similar ".span" + [[email protected]{gridColumns}]
feature support. Well, it's a little too good.
But less support for running JavaScript, there is no too complicated operation, but the string iterative stitching, feel feasible, so there is the following.
Modify this for custom colors, font-sizes, etc@import "variables.less"; equals [class*= "span"] (function (pf,c) {var a=[];while (c>0) {A.push (pf+c); c--;} Return A.join (', ');}) ('. span ', parseint ("@{gridcolumns}")) { float:left; margin:0 @gridGutterWidth 0 0;}
JS as follows: (function (pf,c) {var a=[]; while (c>0) {A.push (pf+c); c--; } return A.join (', ');}) ('. span ', parseint ("@{gridcolumns}"))
Because there is only one line, try to simplify it. pf
is the meaning of the prefix prefix, c
is the iteration, the entry parameter value is parseInt("@{gridColumns}")
, so the change is controlled by variables.less. It doesn't look very intuitive, add a note to the statement.
Replace BootStrap with less JS [class*= "span"]