I'm wondering wether I can combine data-tags with animations in CSS. I have a list of an undefined amount of items which are rendered by a javascript templating engine. As soon as the JS finished rendering them I would like to fade them in one after another without having to write a huge bunch of CSS selectors. This was my initial thought, when i only had about 6 elements been added dynamically. Due to the fact that it might get an undefined amount and should still look good I'm facing the described problem.
Is this possible? How do i need to write my CSS?
li.shown {
-webkit-animation: animateIn .8s forwards;
-moz-animation: animateIn .8s forwards;
animation: animateIn .8s forwards;
-webkit-transition-delay: 0;
-moz-transition-delay: 0;
transition-delay: 0;
-webkit-transition-delay: attr(data-animation-offset ms);
-moz-transition-delay: attr(data-animation-offset ms);
transition-delay: attr(data-animation-offset ms);
}
My listitems might look like this and the data tag is calculated by js:
<li data-animation-offset="2000" class="shown"></li>
Ofcourse the easiest solution is using the good old style tag, but the coolest one might be the css version.
Thanks in advance
attr()
feature, this should work just fine. Those thinking otherwise should make sure they're familiar with the feature :) – Carbonaceousattr()
feature" ... it's not my fault if that's currently an empty set :) – Carbonaceousattr
, being that it can only be used for strings and no unit specification is allowed. No browsers support the CSS3 extensions that do allow one. – Emersen