Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

How to get new position after transform div jquery?

How to get new position after transform? Can anybody please help me to do that.

I used

$('#text').css('-moz-transform','rotate(90deg)');

Now I want to get left and right postion.

When I try to get left and top position it shows left and top position before transform

$('#text').position().left;    
$('#text').position().top;

It shows position before div transform

I want to get the new position. How do i do that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I am trying to solve this issue as well. What the user is saying is this:

Let's say you have a div that is 300px by 200px and the top and left position is: 100, 100.

If you rotate it from the center, the top and left positions of the div has now changed, yet Mozilla still returns the pre-rotated top/left positions. Chrome actually returns the correct values after rotation, but FireFox does not.

If you inspect the element with FireBug, the highlighted area is the div also pre-rotation. So there doesn't appear to be any normal way to get the top and left positions after rotating, unless there is some kind of formula that could calculate it based on the height and width and the angle.

Does anyone know of such a formula, or another way to solve this issue?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...