🍋
Menu
.less Code

Less(更精简的样式表)

Less 是一种 CSS 预处理器,为标准 CSS 添加了变量、混入、嵌套和函数。Less 文件编译为普通 CSS,在 Sass 成为主流之前,它曾因 Bootstrap 框架而特别流行。

MIME 类型

text/x-less

类型

文本

压缩

无损

优点

  • + Variables and mixins reduce CSS repetition
  • + Can compile in the browser without a build step
  • + Simpler syntax than early Sass (no indentation rules)

缺点

  • Declining ecosystem — Sass is more widely used
  • Native CSS custom properties replace many Less features
  • Fewer functions and features than modern Sass

何时使用 .LESS

在已使用 Less 的项目中继续使用;新项目建议使用 Sass 或原生 CSS 自定义属性。

技术细节

Less 使用 @variables、.mixin() 定义、嵌套和内置的颜色操作和数学函数来扩展 CSS。它可以在浏览器端(less.js)或通过 Node.js 在服务端编译。

历史

Alexis Sellier 于 2009 年创建了 Less,作为 Sass 的更简单替代品。Bootstrap 3(2013)使用 Less 作为默认预处理器,推动了广泛采用。Bootstrap 4 切换到 Sass,Less 的使用有所下降。

从 .LESS 转换

转换为 .LESS

相关格式

相关术语