This is the edit of the question to add the following.... animating an object with jquery simply as follows.....
这是添加以下内容的问题的编辑....使用jquery动画对象简单如下.....
$("div").animate({left: '250px'});
But it would be ideal if instead of left:'250'px it could be the target
但如果不是左派,那将是理想的:'250'px它可能是目标
div/class something like this....
$("div").animate({'.title-area-main'});
So this question relates to a bit of html , I have a this class within a div called wrapper ....
所以这个问题与一些html有关,我在一个名为wrapper的div中有一个这个类....
<div class="logo"><img src="images/mthc/logo-main.png" height="150px" width="420px"></div>
it is defined in css as ....
它在css中被定义为....
#wrapper {
left: 50%;
top: 50%;
width:720px;
height:300px;
position:fixed;
margin-top: -50px;
margin-left: -100px;
transform: translate(-25%, -25%);
z-index : 5001;
}
.logo{
float:left;
width:60%;
z-index : 5005;
}
the destination of the class "logo" is to this part of the html page....
类“logo”的目的地是html页面的这一部分....
<a href="index.html" class="tile-area-title fg-white small" alt="musability logo"><img src="images/mthc/logo.png"></a>
and the css styling for this comes with the class "title-area-title" as per the a href link ....
并且为此提供的CSS样式带有“title-area-title”类,根据href链接....
.metro .tile-area .tile-area-title {
position: fixed;
top: 0;
left: 260px;
border: 0 ;
height: 120px;
width: 800px;
}
I know I could use some really cool css3 animation tween to move the logo into place of the a tag. that would be great if I am using internet explorer version 50000 ... so I am basically looking for a jquery way of doing this and currently have no experience of jquery animation if even possible. Any advice would be really helpful.
我知道我可以使用一些非常酷的css3动画补间动画来将徽标移动到标签的位置。如果我使用的是Internet Explorer版本50000,那将是很棒的...所以我基本上都在寻找一种jquery方式来做这个,如果可能的话,目前还没有jquery动画的经验。任何建议都会非常有用。
1 个解决方案
#1
1
To get an element's position :
获得元素的位置:
function getPosition(element) {
var xPosition = 0;
var yPosition = 0;
while (element) {
xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
element = element.offsetParent;
}
return { x: xPosition, y: yPosition };
}
Then you call it like this :
然后你这样称呼它:
var y = getPosition(document.getElementById('mydivID')).y;
var x = getPosition(document.getElementById('mydivID')).x;
#1
1
To get an element's position :
获得元素的位置:
function getPosition(element) {
var xPosition = 0;
var yPosition = 0;
while (element) {
xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
element = element.offsetParent;
}
return { x: xPosition, y: yPosition };
}
Then you call it like this :
然后你这样称呼它:
var y = getPosition(document.getElementById('mydivID')).y;
var x = getPosition(document.getElementById('mydivID')).x;