CSS3 悬挂动画

标签 css

有没有办法使用margin-top实现元素上下弹起的悬挂动画?模仿 flex 的东西。

基本上,我希望第一帧为 margin-top:0px,第二帧为 margin-top:15px; 并且应该是无限的。

最佳答案

网上有很多例子。

从这里查看 tutorial 。它是用纯 CSS 完成的。


我刚刚创建了一个简单的演示。一探究竟。该浏览器可在 webkitmozilla 浏览器上运行。

@-webkit-keyframes bounce {
       from{ -webkit-transform: translate(0px,0px); }
       to { -webkit-transform: translate(0px,-30px); }  
      }

@-moz-keyframes bounce {
       from { -moz-transform: translate(0px,0px); }
       to { -moz-transform: translate(0px,-30px); }  
      }

.bounce{
    display:block;
    height:20px;
    width:20px;
    background:#ff0000;
    border-radius:20px;
    margin:50px;
    -webkit-animation-name: bounce;
        -webkit-animation-duration:.3s;
        -webkit-animation-direction:alternate;
        -webkit-animation-timing-function:linear;
        -webkit-animation-delay:0s;
        -webkit-animation-iteration-count:infinite;
    -moz-animation-name: bounce;
        -moz-animation-duration:.3s;
        -moz-animation-direction:alternate;
        -moz-animation-timing-function:linear;
        -moz-animation-delay:0s;
        -moz-animation-iteration-count:infinite;
}

Check out this demo

希望你喜欢。

关于CSS3 悬挂动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9690148/

相关文章:

python - 导航栏未显示在 bootstrap django 中

css - 为什么我的徽章是椭圆形的?

html - 我的悬停下拉菜单隐藏在内容后面(图片)

javascript - 为什么我的网站可以使用 Safari,而不是 FireFox 或 IE?

html - 未加载字体

javascript - 从 JavaScript 访问 CSS 规则

javascript - 添加链接元素 <a> 到段落 <p> Javascript

html - CSS 将 HTML5 div 集中在屏幕底部

javascript - 具有固定边框大小的 css 比例?

javascript - MSDN "pseudoframe"