I am using vw and vh values in my CSS transform. It causes the css animation to use the actual window width. In this case the cloud image moves from the left to the right of the screen.
This works fine for any window size, except when I resize the window after the css is loaded. Is there a way to recalculate the vw value after resizing?
I cannot use percentages because that doesn't work with transform:translate.
cloud {
animation: cloudanimation 2s linear infinite;
}
@keyframes cloudanimation {
0% {
transform: translateX(10vw);
}
100% {
transform: translateX(90vw);
/* percentages don't work correctly with translate */
/* transform : translateX(90%);*/
}
}