makePositioned

makePositioned(element) -> HTMLElement

Allows for the easy creation of CSS containing block by setting element's CSS position to 'relative' if its initial position is either 'static' or undefined. Returns element.

To revert back to element's original CSS position, use Element.undoPositioned.

Example

Consider the following case:


<p>lorem […]</p>
<div id="container">
  <div id="element" style="position: absolute; top: 20px; left: 20px;"></div>
</div>

example

To position div#element relatively to it's parent element:


$('container').makePositioned();
// -> HTMLElement

Which yields the expected layout:

example