The page has a div (brown rectangle). The page is taller than the viewport (orange rectangle), so it can be scrolled, which means that the div can only be displayed partially or not at all.

What is the easiest algorithm to say how many% div visible in the viewport?
(To simplify the task, the div always fits horizontally into the viewport, therefore, only the Y axis should be taken into account in the calculations).
source share