<percentage>
The percentage is calculated with respect to the width of the generated box's containing block. Note that this is true for 'margin-top' and 'margin-bottom' as well. If the containing block's width depends on this element, then the resulting layout is undefined in CSS 2.1.
Percentages: refer to logical width of containing block
const parentPos = document.getElementById('parent-id').getBoundingClientRect(),
const childPos = document.getElementById('child-id').getBoundingClientRect(),
const relativePos = const {
top: childPos.top - parentPos.top,
right: childPos.right - parentPos.right,
bottom: childPos.bottom - parentPos.bottom,
left: childPos.left - parentPos.left,
};