Where's the documentation for jQuery set version of .position()?
I am not finding the documentation for jQuery set version of .position()? All I see is the get version at http://api.jquery.com/position.
The usage is like:
jQuery(theElement).position({
开发者_开发百科 my: "center",
at: "center",
of: ElementPositionedAgainstTo,
offset: "0 0"
});
That is jQuery UI .position()
Tony's comment is correct. Use:
.css({top:'21px',left:'431px'})
for position relative to parent (which, yes, confusingly is css-wise position:absolute). Unless you truly want to set things absolute to the document edges. In that case use offset(), which does have a setter variant (and will do a hell lot of math for you calculating offsets ascending through the tree)
The usual caveats:
- don't forget px as units. Unless you fancy something else like 'em'...
- object needs CSS style 'position:absolute;' and 'display:block' (unless implicit)
- direct parent must be position:relative (or absolute, but at least something set, as a 'stopper')
精彩评论