I have created a moving sphere animation using CSS and I don't get why background-position doesn't work in the second one one. In the first one, I wrote background-size: 150% 150%; and in the second one I wrote background-size: 100% 100%;.
Why is this happening???
The links to my codepens: -https://codepen.io/theanonymouskoder/pen/eYWWZzE?editors=0100 -https://codepen.io/theanonymouskoder/pen/BaRRKpN?editors=0100
The code
* {
margin: 0px;
padding: 0px;
}
body {
background: black;
overflow: hidden;
}
.sphere {
width: 500px;
height: 500px;
border-radius: 50%;
margin: 10px;
background: radial-gradient(
#ffff00,
#774400
);
background-size: 150% 150%;
animation: turn 3s ease infinite;
}
@keyframes turn {
0% {
background-position: 10% 10%;
}
50% {
background-position: 90% 90%;
}
100% {
background-position: 10% 10%;
}
}
<div class = 'sphere'>
This works nicely
</div>
* {
margin: 0px;
padding: 0px;
}
body {
background: black;
overflow: hidden;
}
.sphere {
width: 500px;
height: 500px;
border-radius: 50%;
margin: 10px;
background: radial-gradient(
#ffff00,
#774400
);
background-size: 100% 100%;
animation: turn 3s ease infinite;
}
@keyframes turn {
0% {
background-position: 10% 10%;
}
50% {
background-position: 90% 90%;
}
100% {
background-position: 10% 10%;
}
}
<div class = 'sphere'>
This works nicely
</div>