diff --git a/lib/html/includes.js b/lib/html/includes.js
index d0608d2e..c3065747 100644
--- a/lib/html/includes.js
+++ b/lib/html/includes.js
@@ -401,7 +401,7 @@ var _MiniProfiler = (function() {
var px = button.offsetTop - 1,
// position next to the button we clicked
windowHeight = window.innerHeight,
- maxHeight = windowHeight - 40; // make sure the popup doesn't extend below the fold
+ maxHeight = windowHeight - px - 40; // make sure the popup doesn't extend below the fold
popup.style[options.renderVerticalPosition] = "".concat(px, "px");
popup.style.maxHeight = "".concat(maxHeight, "px");