最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - How to create a rotating wheel with images in Javascript? - Stack Overflow

programmeradmin2浏览0评论

Hi I have ferris wheel graphic. It has 10 elements that forms a big circle (like a ferris wheel). I want to rotate the circle with 8 <div>s. How can I do that in javascript or HTML5?

Something like this. But I need the pink to be a <div> area so that I can put image on it. Any suggestions&help are very much appreciated.

Hi I have ferris wheel graphic. It has 10 elements that forms a big circle (like a ferris wheel). I want to rotate the circle with 8 <div>s. How can I do that in javascript or HTML5?

Something like this. But I need the pink to be a <div> area so that I can put image on it. Any suggestions&help are very much appreciated.

Share Improve this question edited Sep 14, 2011 at 3:02 Mike Samuel 121k30 gold badges227 silver badges254 bronze badges asked Sep 14, 2011 at 2:24 devzonedevzone 3051 gold badge12 silver badges25 bronze badges 2
  • 2 Perish wheel? You mean ferris wheel? – epascarello Commented Sep 14, 2011 at 2:41
  • Do have any experienced doing it? – devzone Commented Sep 14, 2011 at 2:44
Add a ment  | 

2 Answers 2

Reset to default 2

Here's an example. Using a fairly cross-browser approach.

var rotation = 0
setInterval(function() {
    $('div').css({
        "-moz-transform": "rotate(" + rotation + "deg)",
        "-webkit-transform": "rotate(" + rotation + "deg)",
        "-o-transform": "rotate(" + rotation + "deg)",
        "-ms-transform": "rotate(" + rotation + "deg)"
    });

    rotation = (rotation + 10) % 361
}, 200)

Very similar to IAbstractDownvoteFactory's, but all CSS. I wrote it for webkit browsers, getting the others to work should be evident but will require a lot of copy-paste.

.rotate-me {
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-duration: 8s;
    -webkit-animation-name: rotate;
    -webkit-animation-timing-function: linear;
}

@-webkit-keyframes rotate {
    0% {-webkit-transform: rotate(0deg);}
    100% {-webkit-transform: rotate(359deg);}
}

http://jsfiddle/t2fEW/

发布评论

评论列表(0)

  1. 暂无评论