使用LESS时是否自定义CSS属性? [英] Custom CSS attributes while using LESS?

查看:545
本文介绍了使用LESS时是否自定义CSS属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用SASS已有一段时间了,我真正喜欢的一件事就是如何将它用于我的FlashBuilder项目中,即它支持自定义CSS属性,例如'embedAsCFF'和'unicodeRange'.

I have been using SASS for a while now, and one thing I really like is how I can use it for my FlashBuilder projects also, namely that is supports custom CSS attributes, like 'embedAsCFF' and 'unicodeRange'.

我是第一次尝试LESS,使用这两个自定义属性时,它不会让我编译为CSS:

I'm trying out LESS for the first time, and it will not let me compile to CSS while using these two custom attributes:

    embedAsCFF: true;
    unicodeRange: U+0021, U+0023-U+0026, U+0028-U+002a, U+002c, U+002e-U+0039, U+0040-U+005d, U+0061-U+007d;

我收到编译错误:语法错误..."

I receive a 'Less Compilation Error: Syntax Error...'

任何LESS用户都知道我需要如何添加对这些自定义属性的支持?预先感谢.

Any LESS users know how I need to add in support for these custom attributes? Thanks in advance.

推荐答案

更新:此问题将在LESS 1.4.2版本中解决

不是自定义名称,而是格式问题

在我的实验中似乎出现了这个问题,实际上是您在属性名称中使用大写字母(而不是它们本身是自定义属性). LESS显然不支持大写字母.换句话说,这些工作:

Update: This issue will be resolved in the release of LESS 1.4.2

Not a Custom Name but a Format Issue

It appears on my experimenting that the issue is really the fact that you are using capital letters in the property names (not that they are custom attributes themselves). Capital letters are apparently not supported by LESS. In other words, these work:

embedascff: true;
embed-as-cff: true;
unicoderange: U+0021; //etc.
unicode-range: U+0021; //etc. 

但这不是:

Color: red;

在某些实际的LESS代码本身中,我还没有确定哪些地方可以解决(如果可以通过LESS处理属性规则的方式来解决).我怀疑原因是在 parser.js文件第1578-1584行(截至撰写本文时)为:

I have not for certain isolated where in the actual LESS code itself this might be fixed (if it can be fixed for the way LESS handles the property rules). I suspect the cause is in the parser.js file lines 1578-1584 (as of this writing), which are:

property: function () {
  var name;

  if (name = $(/^(\*?-?[_a-z0-9-]+)\s*:/)) {
    return name[1];
  }
}

这似乎已被过滤掉,允许使用大写字母.我不知道如果将正则表达式更改为允许它们会带来什么后果.

This seems to be filtering out allowing for capital letters. I don't know what the consequences would be if that regular expression was changed to allow for them.

这篇关于使用LESS时是否自定义CSS属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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