带参数的混合:
代码语言:javascript复制<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
/*.animate(@name,@time,@mode,@delay)
{
transition: @arguments;/*这个像是@name,@time,@mode,@delay*/
}
.animate(...)/*获取所有的参数*/
{
transition: @name @time @mode @delay;
}
.animate(@name,...)
{
transition: @arguments;/*...获取除了@name所有的参数*/
}
/*
less中的@arguments和js中的arguments一样, 可以拿到传递进来的所有形参
*/
/*.animate(@name,@time,...)
{
transition: @arguments;
}
div
{
width: 200px;
height: 200px;
background: red;
.animation(all,4s,linear,0s);/*函数调用*/
}
div:hover
{
width: 400px;
height: 400px;
background: blue;
}*/
/*编译后得到的css文件*/
div {
width: 200px;
height: 200px;
background: red;
transition: all 4s linear 0s;
}
div:hover {
width: 400px;
height: 400px;
background: blue;
}
</style>
</head>
<body>
<div></div>
</body>
</html>