CSS scrolltop return 0 - ythy/blog GitHub Wiki
use
pageYOffsetinstead ofscrolltop
pageYOffset
The pageXOffset and pageYOffset properties returns the pixels the current document has been scrolled from the upper left corner of the window, horizontally and vertically.
The pageXOffset and pageYOffset properties are equal to the scrollX and scrollY properties.
These properties are read-only.
Note
For IE8 and earlier, you can use document.documentElement.scrollLeft and document.documentElement.scrollTop instead
conclusion
pageYOffset 支持IE9及以上. 尽量不用scrolltop已保持chrome兼容性