CSS3 Animated Gears

转载 2012年03月21日 12:44:10
CSS3 Animated Gears

CSS3 Animated Gears

In today’s lesson, we have made the animated gears with CSS3. The result looks very nice. I have used CSS3 keyframes, animation and transforms (rotate) in order to achieve this result. Please pay attention – current demo works well in Firefox and Chrome / Safari (webkit).


Here are samples and downloadable package:

Live Demo
download in package

Ok, download the example files and lets start coding !


Step 1. HTML

As usual, we start with the HTML. Here is the html code of our result. There are easy DIV elements.

index.html

<div class="container">
    <div class="gear" id="gear1"></div>
    <div class="gear" id="gear2"></div>
    <div class="gear" id="gear3"></div>
    <div class="gear" id="gear4"></div>
    <div class="gear" id="gear5"></div>
    <div class="gear" id="gear6"></div>
    <div class="gear" id="gear7"></div>
</div>

Step 2. CSS

Here are the CSS styles of our animated gears.

css/layout.css

/* CSS3 keyframes */
@-webkit-keyframes ckw {
    0% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
    }
    100% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
    }
}
@-moz-keyframes ckw {
    0% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
    }
    100% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
    }
}
@-webkit-keyframes cckw {
    0% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
    }
    100% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
    }
}
@-moz-keyframes cckw {
    0% {
        -moz-transform: rotate(360deg);
        -webkit-transform: rotate(360deg);
    }
    100% {
        -moz-transform: rotate(0deg);
        -webkit-transform: rotate(0deg);
    }
}

/* gears */
.gear {
    float: none;
    position: absolute;
    text-align: center;

    -moz-animation-timing-function: linear;
    -moz-animation-iteration-count: infinite;
    -moz-animation-direction: normal;
    -moz-animation-delay: 0;
    -moz-animation-play-state: running;
    -moz-animation-fill-mode: forwards;

    -webkit-animation-timing-function: linear;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-direction: normal;
    -webkit-animation-delay: 0;
    -webkit-animation-play-state: running;
    -webkit-animation-fill-mode: forwards;
}
#gear1 {
    background: url('../images/g1.png') no-repeat 0 0;
    height: 85px;
    left: 31px;
    top: 45px;
    width: 85px;

    -moz-animation-name: ckw;
    -moz-animation-duration: 10s;

    -webkit-animation-name: ckw;
    -webkit-animation-duration: 10s;
}
#gear2 {
    background: url('../images/g2.png') no-repeat 0 0;
    height: 125px;
    left: 105px;
    top: 10px;
    width: 125px;

    -moz-animation-name: cckw;
    -moz-animation-duration: 16.84s;

    -webkit-animation-name: cckw;
    -webkit-animation-duration: 16.84s;
}
#gear3 {
    background: url('../images/g3.png') no-repeat 0 0;
    height: 103px;
    left: 149px;
    top: 118px;
    width: 103px;

    -moz-animation-name: ckw;
    -moz-animation-duration: 13.5s;

    -webkit-animation-name: ckw;
    -webkit-animation-duration: 13.5s;
}
#gear4 {
    background: url('../images/g4.png') no-repeat 0 0;
    height: 144px;
    left: 46px;
    top: 173px;
    width: 144px;

    -moz-animation-name: cckw;
    -moz-animation-duration: 20.2s;

    -webkit-animation-name: cckw;
    -webkit-animation-duration: 20.2s;
}
#gear5 {
    background: url('../images/g1.png') no-repeat 0 0;
    height: 85px;
    left: 127px;
    top: 292px;
    width: 85px;

    -moz-animation-name: ckw;
    -moz-animation-duration: 10s;

    -webkit-animation-name: ckw;
    -webkit-animation-duration: 10s;
}
#gear6 {
    background: url('../images/g2.png') no-repeat 0 0;
    height: 125px;
    left: 200px;
    top: 283px;
    width: 125px;

    -moz-animation-name: cckw;
    -moz-animation-duration: 16.84s;

    -webkit-animation-name: cckw;
    -webkit-animation-duration: 16.84s;
}
#gear7 {
    background: url('../images/g3.png') no-repeat 0 0;
    height: 103px;
    left: 277px;
    top: 217px;
    width: 103px;

    -moz-animation-name: ckw;
    -moz-animation-duration: 13.5s;

    -webkit-animation-name: ckw;
    -webkit-animation-duration: 13.5s;
}

Step 3. Images

I have used next images:

gear 1
gear 2
gear 3
gear 4



ShineTime – A Kick-Ass New jQuery & CSS3 Gallery With Animated Shine Effects

This week I’d like to show you how you can create a kick-ass animated Shine Effect with jQuery & C...

CSS3 animated tooltips

来源【可看效果】:http://www.script-tutorials.com/css3-animated-photo-slider/ CSS3 animated tooltips To...

css3、html5、js笔记(传智播客)

  • 2017年11月20日 14:52
  • 36.29MB
  • 下载

HTML5与CSS3权威指南完整版.pdf

  • 2017年11月28日 15:21
  • 25.8MB
  • 下载

css3实现六边形照片展示

总是在匆忙中不知所措,总是还未做好准备,所有的事情就已经发生。对于大多数人努力程度之低,所以根本就不用拼天赋。每天学习一点点。 今天实现的是,用css3去实现多边形的照片显示。其核心是利用css3中...

CSS3秘笈 第3版

  • 2017年11月23日 22:32
  • 110.95MB
  • 下载

H5 CSS3 bootStrap 的 一些简单事例

  • 2017年11月27日 21:38
  • 1.23MB
  • 下载

CSS3无图片实现华丽折页菜单效果(多浏览器兼容)

http://lanfei.sinaapp.com/2012/05/1255.html Finally 最后当然是给出代码和Demo了: CSS部分: body{ ma...

HTML5+CSS3+jquery应用之美

  • 2017年11月15日 10:35
  • 72.94MB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:CSS3 Animated Gears
举报原因:
原因补充:

(最多只允许输入30个字)