diff --git a/js/affix.js b/js/affix.js
index 552bffa3fed8ec926a6dfc1e2b50269bdd91780d..e025e205623fb335367e871b4e92a17f1e620e94 100644
--- a/js/affix.js
+++ b/js/affix.js
@@ -73,7 +73,7 @@
     this.$element.removeClass(Affix.RESET).addClass('affix' + (affix ? '-' + affix : ''))
 
     if (affix == 'bottom') {
-      this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
+      this.$element.offset({ top: scrollHeight - offsetBottom - this.$element.height() })
     }
   }