摩天轮小动画

在前端网上看到别人写了这么一个小动画,就拿来模仿练习下。

学到的知识点:
1、 @keyframes
2、animation属性

一:首先,@keyframes属性,指定动画名称和动画效果。
用法:@keyframes animation-name { 动画效果 }


或者

具体可以参照:[http://www.w3chtml.com/css3/rules/@keyframes.html]

二、animation属性

具体参照:[http://www.w3chtml.com/css3/properties/animation/animation.html]

这个例子的重点就是这两个属性。下面就是动画的代码:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>摩天轮</title>
<style>
.mtl{
    width: 170px;
    height: 220px;
}
.panel{
    width:114px;
    height: 142px;
    position: relative;
    top: 80px;
    left: 50px;
}
.cars{
    width: 163px;
    height: 163px;
    position: absolute;
    top: 24px;
    left: 35px;
}
.cars img{
    position: absolute;
}
.car1{
    left:65px;
    top: -12px;
}
.car2{
    left: 121px;
    top: 15px;
}
.car3{
    left: 145px;
    top:65px;
}
.car4{
    left: 121px;
    top:120px;
}
.car5{
    left: 65px;
    top:140px;
}
.car6{
    left: 10px;
    top:120px;
}
.car7{
    left: -10px;
    top:65px;
}
.car8{
    left: 10px;
    top:15px;
}
.cars{
    animation: cars 5s linear 1s infinite;
}
.c{
    animation: car 5s linear 1s infinite;
}
 @keyframes car{
    0%   { transform:rotate(0deg); }
    100% { transform:rotate(-360deg); }
}
@keyframes cars{
    0%   { transform:rotate(0deg);  }
    100% { transform:rotate(360deg); }
}

</style>
<div class="mtl">
    <img src="panel.png" class="panel">
    <div class="cars">
        <img src="wheel.png" class="wheel">
        <img src="car1.png" class="car1 c">
        <img src="car2.png" class="car2 c">
        <img src="car1.png" class="car3 c">
        <img src="car2.png" class="car4 c">
        <img src="car1.png" class="car5 c">
        <img src="car2.png" class="car6 c">
        <img src="car1.png" class="car7 c">
        <img src="car2.png" class="car8 c">
    </div>
</div>
</body>
</html>

不积跬步无以至千里

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    love2013阅读 2,456评论 0 11
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 2,133评论 0 2
  • 1、属性选择器:id选择器 # 通过id 来选择类名选择器 . 通过类名来选择属性选择器 ...
    Yuann阅读 1,764评论 0 7
  • 01 上周六的时候,我亲眼看见室友肖颖对着她的妈妈大喊大叫。 而她有这样的举动,仅仅是因为一台单反。 肖颖想买一款...
    谢筱言阅读 343评论 0 1
  • 生如夏花之绚烂, 死如秋叶之静美。 一地黄叶, 寒艳不招春妒。 袅袅兮秋风, 萧瑟兮黄叶下。 笑潜风冷舞寒秋, 至...
    风吹花海阅读 255评论 2 5

友情链接更多精彩内容