绝对位置转换为相对位置 [英] Convert absolute position to relative
本文介绍了绝对位置转换为相对位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将DIV位置从绝对位置改变为相对位置(以及相对于绝对位置)?
DIV应保持在同一地点。
解决方案
您可以使用
$(object).css({position:'absolute'});
例如:
您可以使用jQuery的方法 .position()
或 .offset()
设置top和left
css属性也是如此,应该留在它的位置上,从相对 - >绝对值改变
。
我认为这反过来也是一样。
演示代码: http://jsbin.com/uvoka
Is it possible to change DIV position from absolute to relative (and from relative to absolute)? DIV should remain on same place.
解决方案
you can change that attribute with
$(object).css({position: 'absolute'});
For instance:
You could use jQuery's methods .position()
or .offset()
to set "top" and "left"
css attribute aswell, that way your object should stay at it's position changing
from relative -> absolute.
I don't think that works vice versa.
demo code: http://jsbin.com/uvoka
这篇关于绝对位置转换为相对位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文