animation - 鼠标悬停时CSS3背景旋转动画

标签 animation css background rotation css-transitions

这是我的 div。

   #div1{
        position:   absolute;
        top:        50%;
        left:       50%;
        margin-left:-100px;
        margin-top: 420px;
        width:      158px;
        height:     158px;
        background-image:url(images/background.png);
    }

对于鼠标悬停事件,我需要 360 度的背景图像旋转动画。有谁能够帮助我?谢谢。

最佳答案

这是您的要求:

jsFiddle Demo

    <div id="div1">rterterrt
teteterrtetre<div id="div2">
</div></div>

.

 #div1{
        position:   absolute;
        top:        50%;
        left:       50%;
        margin-left:-100px;
        /*margin-top: 420px;*/
        width:      158px;
        height:     158px;

}
#div2{


        /*margin-top: 420px;*/
        width:      158px;
        height:     158px;
        background-image:url(http://www.commentsyard.com/cy/01/6474/Mixed%20Flowers%20and%20a%20Bear.jpg);
}

#div2:hover {
    -webkit-animation-name: rotate; 
    -webkit-animation-duration: 2s; 
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-timing-function: linear;
    -moz-animation-name: rotate; 
    -moz-animation-duration: 2s; 
    -moz-animation-iteration-count: infinite;
    -moz-animation-timing-function: linear;
}
@-webkit-keyframes rotate {
    from {-webkit-transform: rotate(0deg);}
    to {-webkit-transform: rotate(360deg);}
}
​

关于animation - 鼠标悬停时CSS3背景旋转动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12506305/

相关文章:

java - 在android中获取按钮的ID

c# - .NET MAUI 中 X 轴的自定义动画

javascript - 滚动到时开始动画

ios - 向固定点旋转箭头(类似时钟的动画)

css - 无法让 Shiny App 中的 Navbar 看起来正常

audio - FFMPEG 连接音频文件并添加背景音乐

javascript - 启动/停止 webkit 动画 onclick 而不是 :hover

css - 如何使用 CSS 使表格响应式

html - 如何将导航栏移动到水平居中?

java - 背景颜色问题