This plugin does nothing else but – as you might have guessed – aligns an absolutely positioned layer relative to another. You can choose which corner of the layer to align to the target’s which corner. As easy as can.
Syntax
$(layer).alignTo(target, { options });
target
selector or jQuery elementgap
the distance between the two elements’ edges
options
posX
,posY
reference point of the element to be aligned
0 = ALIGN_LEFT
|1 = ALIGN_CENTER
|2 = ALIGN_RIGHT
,
0 = ALIGN_TOP
|1 = ALIGN_MIDDLE
|2 = ALIGN_BOTTOM
toX
,toY
reference point of the target element ( the same as above )
Examples
[read-code path="/static/alignto-plugin/sample.html"]
Requirements
License
Available for use in all personal or commercial projects under both MIT and GPL licenses.
Copyright (c) 2012 Laszlo Molnar