Method 1:
You have the option of using .parentNode to retrieve the parent element (if direct access is not available), and then obtaining the height of the parent. It should be equal to the portion of the child div that remains within the parent div, as illustrated below:
document.getElementById("#id).parentNode.style.height
Method 2: (even effective if the child div has been repositioned)
If accessing the parent element is not an issue, you can achieve a more precise solution by acquiring the coordinates of both the parent and child elements. With a bit of mathematical calculation, you can pinpoint the exact section where the child div intersects with the parent div...
let parentCoord = document.getElementById('parentId').getBoundingClientRect();
let childCoord = document.getElementById('childId').getBoundingClientRect();
var left = Math.max(parentCoord.left, childCoord.left);
var right = Math.min(parentCoord.right, childCoord.right);
var top = Math.max(parentCoord.top, childCoord.top);
var bottom = Math.min(parentCoord.bottom, childCoord.bottom);
Now, you possess the precise coordinates of the area where the child div overlaps with the parent div. If you require the width, a straightforward calculation can be performed:
var width = right - left;
var height = bottom - top;
If this solution aligns with your needs, feel free to implement it. In case further clarification or assistance is required, do provide additional details about your objective...
Otherwise, happy coding!