@Keyframes don't move my div

流过昼夜 提交于 2019-12-25 01:53:53

问题


i'm trying to make my div moves up and down with CSS3, but it doesn't

<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;
}

you can see my code here: http://jsfiddle.net/LGMv7/1/


回答1:


Add to your .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




回答2:


your div Need ! position absolute! try!

or apply the property transform, whit transform you div.globo not need position abosolute!



来源:https://stackoverflow.com/questions/22002118/keyframes-dont-move-my-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!