I have a background image that I want to continuously scroll from right to left. I want the image to cover the entire screen, but when I set background-size: cover;
it does not animate at all. How can I fix this?
HTML
<body>
...
</body>
CSS
body {
background-color: rgb(15, 5, 40);
background-image: url('./images/star background.png');
background-repeat: repeat;
background-position: top left;
background-size: cover;
animation: myMove 3s linear infinite;
}
@keyframes myMove {
from { background-position-x: right; }
to { background-position-x: left }
}
If I set background-size #px #px;
or initial
or X% Y%
then it works fine, but doesn't cover the whole screen? Also, here is the image:
Here is another idea using translate on pseudo element where you make the element big to have enough room for an infinite movement: