使用LESS mixin添加供应商前缀 [英] Adding vendor prefixes with LESS mixin

查看:88
本文介绍了使用LESS mixin添加供应商前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此混入出现语法错误:

.vendors(@statement){
  @statement;
  -moz-@statement;
  -webkit-@statement;
}

任何执行此操作的方法,或者混入变量必须位于:的右侧吗?

Any way to do this, or do mixin variables have to be on the right side of a :?

推荐答案

由于v2较少,您可以使用 autoprefixer后处理器添加浏览器前缀.对于客户端编译(在浏览器中),您可以使用 -prefixfree .

Since Less v2 you can use the autoprefix plugin to prefix your properties, which seems to be a better alternative. The autoprefix plugin add browser prefixes leveraging the autoprefixer postprocessor. For client side compiling (in the browser) you can use -prefixfree.

@ScottS已在中提及从Less v1.6开始,您就可以在选择器中使用变量插值,从而可以执行以下操作:

As already mentioned by @ScottS here you can use variable interpolation in selectors since Less v1.6, which enables you to do:

.prefix(@property, @value)
{
    -webkit-@{property}:@value;
    @{property}:@value;
}
selector {
    .prefix(property,value);
}

输出:

selector {
  -webkit-property: value;
  property: value;
}

您还应该阅读:我为我的LESS过于复杂了供应商前缀?

这篇关于使用LESS mixin添加供应商前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆