gpt4 book ai didi

html - 在 CSS 中旋转地球

转载 作者:技术小花猫 更新时间:2023-10-29 11:30:43 27 4
gpt4 key购买 nike

我正在 CSS 中创建一个旋转的地球效果。我用 CSS 创建了地球:

body {
background-color: #111;
}

#earth {
width: 300px;
height: 300px;
background: url(https://web.archive.org/web/20150807125159if_/http://www.noirextreme.com/digital/Earth-Color4096.jpg);
border-radius: 50%;
background-size: 610px;
box-shadow: inset 8px 36px 80px 36px rgb(0, 0, 0),
inset -6px 0 12px 4px rgba(255, 255, 255, 0.3);
animation-name: rotate;
animation-duration: 12s;
animation-iteration-count: infinite;
animation-timing-function: linear;
-webkit-animation-name: rotate;
-webkit-animation-duration: 12s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}

@keyframes rotate {
from { background-position: 0px 0px; }
to { background-position: 500px 0px; }
}
@-webkit-keyframes rotate {
from { background-position: 0px 0px; }
to { background-position: 500px 0px; }
}
<div id="earth"></div>

但它停止了,然后图像重置并重新开始。我希望它平稳移动而不会抽搐。非常感谢!

最佳答案

background-position: 500px 0px;中将500px替换为610px,即background-size

body {
background-color: #111;
}
#earth {
width: 300px;
height: 300px;
background: url(https://web.archive.org/web/20150807125159if_/http://www.noirextreme.com/digital/Earth-Color4096.jpg);
border-radius: 50%;
background-size: 610px;
box-shadow: inset 8px 36px 80px 36px rgb(0, 0, 0), inset -6px 0 12px 4px rgba(255, 255, 255, 0.3);
animation-name: rotate;
animation-duration: 12s;
animation-iteration-count: infinite;
animation-timing-function: linear;
-webkit-animation-name: rotate;
-webkit-animation-duration: 12s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
@keyframes rotate {
from {
background-position: 0px 0px;
}
to {
background-position: 610px 0px;
}
}
@-webkit-keyframes rotate {
from {
background-position: 0px 0px;
}
to {
background-position: 610px 0px;
}
}
<div id="earth"></div>

关于html - 在 CSS 中旋转地球,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27781634/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com