-4
地球旋转的原始代码:地球为什么不能像图像一样旋转?
<style>
.earth {
\t position:absolute;
\t top:0;
\t bottom:0;
\t left:0;
\t right:0;
\t margin:auto;
width: 677px;
\t height: 677px;
\t background: url(http://pic.58pic.com/58pic/17/52/66/05S58PICEZC_1024.jpg);
\t border-radius: 50%;
\t background-size: cover;
\t box-shadow: inset -30px -30px 60px 2px rgb(0, 0, 0),
\t \t inset 0 0 20px 2px rgba(255, 255, 255, 0.2);
\t animation-direction:normal;
\t animation-name: rotate;
\t animation-duration: 4s;
\t animation-iteration-count: infinite;
\t !--animation-timing-function: linear;--!
\t animation-fill:forwards;
}
@keyframes rotate {
\t 0% {background-position: 0 0;}
100% {background-position: 1024px 0;}
\t }
.earth:hover{
-webkit-animation-play-state:paused;
}
.hover_img a { position:relative; }
.hover_img a span { position:absolute; display:none; z-index:99; }
.hover_img a:hover span { display:block; }
</style>
<div class="earth"></div>
但为什么它是静态的,如下的图像? 而悬停功能也不起作用。
<style>
.earth {
\t position:absolute;
\t top:0;
\t bottom:0;
\t left:0;
\t right:0;
\t margin:auto;
\t width: 677px;
\t height: 677px; \t
\t border-radius: 50%;
\t box-shadow: inset -30px -30px 60px 2px rgb(0, 0, 0),
\t \t inset 0 0 20px 2px rgba(255, 255, 255, 0.2);
\t animation-direction:normal;
\t animation-name: rotate;
\t animation-duration: 4s;
\t animation-iteration-count: infinite;
\t animation-timing-function: linear;
\t animation-fill:forwards;
}
@keyframes rotate {
\t 0% {position: 0px 0px;}
100% {position: 1024px 0px;}
\t }
.earth:hover{
-webkit-animation-play-state:paused;
}
.hover_img a { position:relative; }
.hover_img a span { position:absolute; display:none; z-index:99; }
.hover_img a:hover span { display:block; }
</style>
<div>
<img src="http://pic.58pic.com/58pic/17/52/66/05S58PICEZC_1024.jpg" usemap="#map" class="earth"/>
<map name="map">
<area shape="poly" coords="224,330,239,325" href="images/diru.png" alt="" class="hover_img">
</map>
</div>
我想画一个旋转的地球与显示在悬停在地图热点另一幅图像。但是,如果我在CSS中使用背景图像,我发现代码工作正常,如果只是将图像放入页面,则代码会失败。如果悬停功能失败,则需要单击地图热点才能显示新图像。当点击新图像屏幕上的任何地方时,我需要一个功能返回到地球图像。请帮忙!
第1步:验证您的CSS。你设法在那里粘贴奇怪的字符,比如'top:0;',这不是一个普通的分号,但是其他的东西(使得这个和下面的属性无效),你设法通过'background-size'进入不存在的财产'大小',... – CBroe
谢谢你的笔记。我解决了这些问题,但第二代码仍然无法旋转地球。 – arexw
相关:https://stackoverflow.com/questions/16771225/css3-rotate-animation – Abra001