Doesn't work inline css animation like this:
<h1 class="test" style="animation: bg 2s linear infinite">Hello {name}!</h1>
<style>
.test {
background: yellow;
}
@keyframes bg {
from {
background: red;
}
to {
background: green;
}
}
</style>
https://svelte.dev/repl/e32b72cb98cb4b78a47b1bcb1ecab9e9?version=3.53.1
But if delete style attribute
<h1 class="test">Hello {name}!</h1>
and add
.test
background: yellow;
animation: bg 2s linear infinite;
}
It works! But I want to add animation as inline style.
animation
is a shorthand property. If you need variance in e.g. just the speed, you could define everything exceptanimation-duration
in the<style>
tag. – Nonpartisan