1

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
}

// ...
Pete
  • 57,112
  • 28
  • 117
  • 166
Yovav
  • 2,557
  • 2
  • 32
  • 53
  • You can create a LESS mixin that uses a parameter, but you cannot use parameters in the CSS. That is, you cannot do something like `
    ` unless you have defined a class named `.opacity(20)`.
    – connexo Dec 06 '16 at 10:49
  • this is not possible with css. also ie 5- 7? these browsers are dead and no longer supported by microsoft – Pete Dec 06 '16 at 10:50
  • Maybe I can use jQuery to modify specific class names on the fly, but I was looking for a better way... – Yovav Dec 06 '16 at 13:05
  • Duplicate of [Can less.js read class names and parameters from HTML?](https://stackoverflow.com/questions/17104746/can-less-js-read-class-names-and-parameters-from-html) – seven-phases-max Nov 06 '17 at 11:22

0 Answers0