-5
我有以下代碼可以在滾動過100像素時看到ID。在Javascript中使用百分比值
window.onscroll = function() {stickyHeader()};
function stickyHeader() {
if (document.body.scrollTop > 100 document.documentElement.scrollTop > 100) {
document.getElementById(sticky-header).style.visibility= visible;
} else {
document.getElementById(sticky-header).style.visibility= hidden;
}
}
如何將scrollTop >100
值中的100像素更改爲頁面的80%?
多個頁面被.8高度? – epascarello
您可能需要'(document.documentElement.scrollHeight - window.innerHeight)* 0.8' ... –