Reputation: 7299
In css
we have something similair for :pseudo
elements. According to this, it will come in the future. At the moment its not supported by any major browser http://caniuse.com/#feat=css3-attr
.test {
display: inline-block;
background-color: gray;
color: attr(data-color); /* Doens't work in css */
width: attr(data-width px);
}
.test:after {
content: attr(data-name);
}
<div class='test' data-name=" - CONTENT" data-color="#f00" data-width="200">test</div>
But what i want is, lets say ive the following div
<div data-color="#f00">...</div>
In LESS
i want to be able to pick that color through the data
attribute.
.example-class {
color: attr(data-color); /* Something like this */
}
Is this, or something similar, possible using LESS
?
Upvotes: 0
Views: 3834
Reputation: 723498
Considering that LESS compiles to CSS anyway, and therefore never knows about the HTML, that doesn't seem possible. That is the entire reason why the attr()
function is in CSS, not LESS.
Upvotes: 3