Less CSS - class declaration in html?

2019-08-30 05:07发布

I get where less could be used, but doing this (which doesn't work):

<div class="fixed-width(150px)" ></div>

.fixed-width(@customWidth) {
   width: @customWidth;
}

...seems like it makes more sense than the offered example of:

<div class="fixed-width" ></div>

.fixed-width {
   .another-step(150px);
}

.another-step(@customWidth) {
   width: @customWidth;
}

Is there an easy way to accomplish this I'm missing?

标签: css less
1条回答
冷血范
2楼-- · 2019-08-30 05:39

No. LESS compiles the CSS file only, not the inline CSS as well. You'd have to write an improved parser to generate the code you're already using.

查看更多
登录 后发表回答