支持查询的CSS预处理器

标签 css less

我需要以下功能:

/* define rule */
div.primary { padding: 12px 0 0 0; }

/* use it */
div.secondary { @(div.primary, padding-top) }
/* or */
div.secondary { padding-top: @(div.primary).padding-top }

看起来 lesscss 不支持这样的查询。也许扩展它是最好的方法?那怎么扩展呢?

更新:我发现 less 的作者决定放弃此功能:https://github.com/cloudhead/less.js/issues/6

最佳答案

你必须更加间接。定义一个变量并使用它,就像这样:

@topPad: 12px;

/* use it to define rule */ 
div.primary { padding: @topPad 0 0 0; } 

/* use it again */ 
div.secondary { padding-top: @topPad;}

关于支持查询的CSS预处理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10555143/

相关文章:

html - 如何删除复选框边框?

css - 如何在 less 中循环遍历一组变量?

html - 这是一种纠正绝对 iframe 的 Internet Explorer View 的方法吗?

javascript - GoJS 中链接上方的图标

meteor - 如何使用@import 在meteor 中使用更少的mixin 而不会获得多个定义

css - LESS CSS 和 RetinaJS 错误

less - 获取加载的LESS文件,按需编译

html - Bootstrap 3 网格在 less 与在 html 中的比较

css - 用于定位和设计的表格与 CSS

jquery - Bootstrap 导航栏响应