html - 为什么背景位置属性在这里不起作用
问题描述
我已经使用 CSS 创建了一个移动球体动画,但我不明白为什么background-position
在第二个动画中不起作用。第一个是我写background-size: 150% 150%;
的,第二个是我写的background-size: 100% 100%;
。
为什么会这样???
我的代码笔的链接:-https://codepen.io/theanonymouskoder/pen/eYWWZzE?editors=0100 -https://codepen.io/theanonymouskoder/pen/BaRRKpN?editors=0100
编码
* {
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>