I just learned that I can select elements by using data-attributes, which is great. I then want to stylize these elements differently based on certain calcutions. for example, I want to have 4 varieties of style, and I want to use modulus of the existing [data-pid]
attribute of the elements to help determine the style.
For example, imagine there are a set of divs containing text that has one of four font colors (e.g. red, orange, yellow, or green), and that an individual div's color depends on its modulus of four. I believe the CSS (if it is possible) would go something like this:
div[0=data-pid-modulus-by-4]{
color: red;
}
div[1=data-pid-modulus-by-4]{
color: orange;
}
div[2=data-pid-modulus-by-4]{
color: yellow;
}
div[3=data-pid-modulus-by-4]{
color: green;
}
Is it possible to calculate the modulus of a data-pid/attribute using just CSS in a way similar to what I illustrate above or do I have to use javascript to accomplish this modulus of an attribute's value? If it is not possible can someone suggest the smallest/easiest js solution they can think of to do it?
Thanks!