position-element DEMO
Select anchor element
Select placement
toggle auto reposition
( reposition when element goes out of viewport )
Adjust distance and offset
Code Example
var config = {
element: document.getElementById('subject'),
anchorElement: document.getElementById('anchor'),
preferredPlacement: 'down-center',
distance: 10,
alignmentOffset: 0,
autoReposition: true,
};
positionElement(config);