How to pass a parameter to a CSS class using LESS?

a 夏天 提交于 2019-12-20 04:10:05

问题


Not sure if this is possible using LESS, but I saw .rotate(@degrees) {...} (is that only work in LESS)

I want to be able to write one CSS class and pass the number as a parameter from the HTML - for example: <div class="opacity(20)">

Here is just an example of a repeated CSS class that I use (but even passing an integer will be great):

.opacity-10 {
  opacity: 0.1;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)"; // IE 8
  filter: alpha(opacity=10); // IE 5-7
  -moz-opacity: 0.1; // Netscape
  -khtml-opacity: 0.1; // Safari 1.x
}
.opacity-20 {
  opacity: 0.2;
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=20)"; // IE 8
  filter: alpha(opacity=20); // IE 5-7
  -moz-opacity: 0.2; // Netscape
  -khtml-opacity: 0.2; // Safari 1.x
}

// ...

来源:https://stackoverflow.com/questions/40993082/how-to-pass-a-parameter-to-a-css-class-using-less

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!