简体   繁体   English

如何围绕徽标创建三个元素的轨道

[英]How to create an orbit of three elements around a logo

I'm a newbie and I'm on my first project: 我是新手,我正在进行第一个项目:

I have three elements (images) and a logo. 我有三个元素(图像)和一个标志。

When I click on an image this one and the other two ones should move in an orbit of 360° around the logo (with a low z-index when they go on the back of the logo so they can disappear and then reappear). 当我点击图像时,这一个和另外两个应该围绕徽标在360°的轨道上移动(当它们在徽标背面时具有低z-index,因此它们可以消失然后重新出现)。

Is this possible with jquery and css3? 这有可能与jquery和css3?

Hiya 2 demos starts with simple: Hiya 2演示从简单开始:

1) (using divs) http://jsfiddle.net/ErN8X/2/show & code: http://jsfiddle.net/ErN8X/2/ 1)(使用的div) http://jsfiddle.net/ErN8X/2/show &代码: http://jsfiddle.net/ErN8X/2/

2) http://jsfiddle.net/qXP7H/show/ and code: http://jsfiddle.net/qXP7H/ 2) http://jsfiddle.net/qXP7H/show/和代码: http//jsfiddle.net/qXP7H/

Please see here as well: jQuery plugin to make an element orbit another? 请看这里: jQuery插件使元素轨道成为另一个?

For the second demo you can copy paste the code from jsfiddle. 对于第二个演示,您可以复制粘贴来自jsfiddle的代码。 rest this should help, have a nice one, and don't forget to accept answer if this helps.! 休息这应该有所帮助,有一个好的,如果这有帮助,不要忘记接受答案。 :) :)

Jquery for simple demo Jquery简单演示

var angle = 0;     // starting position (degrees)
var distance = 30; // distance of b from a
var speed = 60;    // revolution speed in degrees per second
var rate  = 10;    // refresh rate in ms

function f() {

    var o = $('#a').offset();

    var t = o.top + (distance * Math.sin(angle * Math.PI/180.0));
    var l = o.left+ (distance * Math.cos(angle * Math.PI/180.0));

    $('#b').css({
        top: t,
        left: l
    });
    $('#c').css({
        top: t + 20,
        left: l + 30
    });
    $('#d').css({
        top: t +40,
        left: l +40
    });
    angle += (speed * (rate/1000)) % 360;
}

setInterval(f, rate);
​

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM