How can I use attr()
to select the data attribute and set various CSS properties based off the value? For example I have this jsfiddle http://jsfiddle.net/rh1vfmso/ - I set the width via data-width then try to set it via width: attr(data-width);
It works when I set the content as the attribute but nothing else. How would I be able to set the width based off what's set in the attribute in HTML?
<style type='text/css'>
input[type='checkbox']:checked ~ .size:before {
content: attr(data-width);
display: block;
height: 30px;
background-color: red;
width: attr(data-width);
/*width: 100px;*/
}
</style>
<div>
<input type='checkbox' id='resize'>
<label for='resize'>Resize</label>
<div class="size" data-width=100px></div>
</div>