I have a css transform that rotates objects on hover.
.rotate { transition: 0.2s; }
.rotate:hover { transform: rotate(20deg); }
This works perfectly fine when applied to a hard coded HTML element.
However the page contains a script that generates more HTML and inserts it into a div (div.innerHTML = newHTML).
The css transitions do not work on any elements generated by the script.
Why would this be the case and how can it be corrected?
EDIT: Here is a simplified example that shows my code, however I'm unable to get the example to work at all, the hard coded rotate and the generated html don't rotate and I have no idea why.
<!doctype html>
<head>
<style>
.rotate {
transition: 0.2s;
}
.rotate:hover {
transform: rotate(20deg);
}
</style>
</head>
<body>
<a class="rotate" href="#">A test text</a>
<div id="plot"></div>
<script>
function makeHTML()
{
return '<a class="rotate" href="#">I am a HTML link</a>';
}
var plot = document.getElementById('plot');
var text = makeHTML();
plot.innerHTML = text;
</script>
</body>
</html>
transitionandtransformproperties are not overridden by rules applied by more specific selectors in your CSS, the ones you specified should apply. The simplest way to figure it out is to inspect the added elements, go to "Computed" (near "Styles") tab and check what's specified intransitionandtransformproperties for the element. It will also tell you what rule sets them. Without a minimal reproducible example we can't help you more than this.