html - @Keyframes 不要移动我的div

标签 html css css-animations

我试图用 CSS3 使我的 div 上下移动,但它没有

<div class="globo"></div>

@-webkit-keyframes mover {
    0%, 100% { top: 0%;}
    50% { top: 5%; }
}
@-moz-keyframes mover {
    0%, 100% { top: 0%;}
    50% { top: 5%; }
}
@-o-keyframes mover {
    0%, 100% { top: 0%;}
    50% { top: 5%; }
}
@keyframes mover {
    0%, 100% { top: 0%;}
    50% { top: 5%; }
}
.globo{
    float: left;
    height: 300px;
    width: 270px;
    background: url('https://lh3.ggpht.com/-hCYXxhc-U4BqD1CBVCARXlp1bPT7ci7pP1Q4NEOzIKpS8zKPfyCCQF5xjEVUf4vGrJ2=w300');
    -webkit-animation: mover 5s infinite; /* Safari 4+ */
     -moz-animation:    mover 5s infinite; /* Fx 5+ */
     -o-animation:      mover 5s infinite; /* Opera 12+ */
    animation:         mover 5s infinite;
}

你可以在这里看到我的代码:http://jsfiddle.net/LGMv7/1/

最佳答案

添加到您的 .globo

position: absolute;


.globo{
    float:left;
    position: absolute;
    height: 300px;
    width: 270px;
    background: url('https://lh3.ggpht.com/-hCYXxhc-U4BqD1CBVCARXlp1bPT7ci7pP1Q4NEOzIKpS8zKPfyCCQF5xjEVUf4vGrJ2=w300');
    -webkit-animation: mover 5s infinite; /* Safari 4+ */
     -moz-animation:    mover 5s infinite; /* Fx 5+ */
     -o-animation:      mover 5s infinite; /* Opera 12+ */
    animation:         mover 5s infinite;
}

demo

关于html - @Keyframes 不要移动我的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22002118/

相关文章:

php - HTML 定义激活的选择选项

javascript - 填充数据时禁用图像

html - Bootstrap 创建额外的 <a> 标签

javascript - 使动画关键帧无限重复

css - SVG旋转动画回收循环摆动

css - 展开圆的宽度

javascript - 触发事件时隐藏/显示元素

javascript - 单击菜单时覆盖(并删除边框)

javascript - 滚动时如何使网站捕捉到下一个 anchor ?

javascript - 如何在一个页面中打开多个对话框?