本文介绍了如何阅读这个 LESS css?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出 Joni Korpi 的无框架 CSS 无框架网格 (http://framelessgrid.com/) 和我很难阅读他拥有的 .less 文件.我对 LESS 使用变量有一个基本的了解,所以我知道 column = 48 和 gutter = 24 就是这样.

I am trying to figure out Joni Korpi's Frameless CSS frameless grid (http://framelessgrid.com/) and I'm having a hard time reading the .less file he has. I have a basic understanding that LESS uses variables so I know column = 48 and gutter = 24 and that's about it.

1cols = 1 * (48 + 24) - 24)/12 吗?

Does 1cols = 1 * (48 + 24) - 24)/ 12 ?

我不明白的是 @1col: @1cols;.width (@cols:1) {宽度:(@cols * (@column + @gutter) - @gutter)/@em;}

有人可以帮忙吗?

https://github.com/jonikorpi/Frameless/blob/master/无框架.无

@font-size: 16;         // Your base font-size in pixels
@em: @font-size*1em;    // Shorthand for outputting ems, e.g. "12/@em"

@column: 48;    // The column-width of your grid in pixels
@gutter: 24;    // The gutter-width of your grid in pixels


//
// Column-widths in variables, in ems
//

 @1cols: ( 1 * (@column + @gutter) - @gutter) / @em; @1col: @1cols;
 @2cols: ( 2 * (@column + @gutter) - @gutter) / @em;
 @3cols: ( 3 * (@column + @gutter) - @gutter) / @em;
 @4cols: ( 4 * (@column + @gutter) - @gutter) / @em;
 @5cols: ( 5 * (@column + @gutter) - @gutter) / @em;
 @6cols: ( 6 * (@column + @gutter) - @gutter) / @em;
 @7cols: ( 7 * (@column + @gutter) - @gutter) / @em;
 @8cols: ( 8 * (@column + @gutter) - @gutter) / @em;
 @9cols: ( 9 * (@column + @gutter) - @gutter) / @em;
@10cols: (10 * (@column + @gutter) - @gutter) / @em;
@11cols: (11 * (@column + @gutter) - @gutter) / @em;
@12cols: (12 * (@column + @gutter) - @gutter) / @em;
@13cols: (13 * (@column + @gutter) - @gutter) / @em;
@14cols: (14 * (@column + @gutter) - @gutter) / @em;
@15cols: (15 * (@column + @gutter) - @gutter) / @em;
@16cols: (16 * (@column + @gutter) - @gutter) / @em;


//
// Column-widths in a function, in ems
//

.width (@cols:1) {
width: (@cols * (@column + @gutter) - @gutter) / @em;
}

推荐答案

@1cols 等只是变量名.less 中的变量名称允许以数字开头.

@1cols etc are just variable names. Variable names in less are allowed to start with numbers.

@1col: @1cols;

那只是说变量@1col 等于之前设置的变量@1cols.据推测,1col"是因为 1 是单数,但其他是复数,所以它只是让您选择使用 @1col@1cols 它们都是相同的值.

That's just making the saying that variable @1col equals the variable @1cols set earlier. Presumably, "1col" because 1 is singular, but the others are plural, so it just gives you the option of using either @1col or @1cols both of them being the same value.

@1cols: ( 1 * (@column + @gutter) - @gutter) / @em;

那只是数学.如果您想要一个 3 列宽的部分,那就是(列宽 + 装订线宽度)减去一个装订线的 3 倍.

That's just math. If you want a section that's 3 columns width, that's 3 times the (column width + gutter width) minus one gutter.

.width (@cols:1) {
width: (@cols * (@column + @gutter) - @gutter) / @em;
}

这是一个混合函数,它采用可变数量的列,默认参数为 1.您可以像这样使用它:

That's a mixin function that takes a variable number of columns with a default parameter of 1. You can use it like this:

.my-class{
   .width(3);
}
/* these two are identical */
.my-class{
   width: @3cols;
}

第一种方法的好处是你可以用一个变量替换3,这样你就可以在其他地方使用它.

The benefit of the first method is that you can replace 3 with a variable so you can use it elsewhere.

这篇关于如何阅读这个 LESS css?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 07:22