小编Fau*_*dia的帖子

Bootstrap 响应边距和填充 Less/CSS

我创建了一系列 CSS 类来轻松操作各种元素的边距和填充。我还利用媒体查询来创建仅适用于特定屏幕宽度的响应类。一切似乎都正常运行,但正如您所看到的,我的 Less 写作技巧非常缺乏,代码量很大!

我知道可用于输出所需 CSS 的代码要少得多,但我编写自定义 mixin 和循环的所有尝试都失败了。

是否可以将这段代码减少到更简洁的程度?任何帮助,将不胜感激。

干杯!

// Margins and padding
// -------------------------

// Horizontal and vertical offset values
@x-0:       0;
@x-xs:      (@grid-gutter-width / 4);
@x-sm:      (@grid-gutter-width / 2);
@x-md:      @grid-gutter-width;
@x-lg:      (@grid-gutter-width * 2);
@x-xl:      (@grid-gutter-width * 4);

@y-0:       0;
@y-xs:      (@line-height-computed / 4);
@y-sm:      (@line-height-computed / 2);
@y-md:      @line-height-computed;
@y-lg:      (@line-height-computed * 2);
@y-xl:      (@line-height-computed * 4);

// Static margins
.mt-0  { margin-top: @y-0; }
.mt-xs { margin-top: @y-xs; }
.mt-sm { margin-top: …
Run Code Online (Sandbox Code Playgroud)

css less responsive-design twitter-bootstrap

6
推荐指数
1
解决办法
3万
查看次数

标签 统计

css ×1

less ×1

responsive-design ×1

twitter-bootstrap ×1