扫码一下
查看教程更方便
less 将 javascript 代码映射到对值的操作,并使用预定义的函数来操作样式表中的 html 元素方面。 它提供了几个函数来操作颜色,如 round
函数、floor
函数、ceil
函数、percentage
函数等。
下面的例子演示了less文件中函数的使用
operations.html
迹忆客(jiyik.com) - less 函数 less enables customizable, manageable and reusable style sheet for web site.
接下来,创建文件 style.less。
style.less
@color: #ff8000; @width:1.0; .mycolor { color: @color; width: percentage(@width); }
我们可以使用以下命令将 style.less 文件编译为 style.css
$ lessc style.less style.css
执行上述命令; 它将使用以下代码自动创建 style.css 文件
style.css
.mycolor { color: #ff8000; width: 100%; }
按照以下步骤查看上述代码的工作原理