效果图
html代码
<div id="box"></box>
css代码
html,body{
height: 1000px;
}
#box{
width: 100%;
height: 200px;
background-color: red;
position: fixed;
bottom: 0;
display: none;
}
JavaScript代码
var box = document.getElementById('box');
if (navigator.userAgent.indexOf('Firefox') != -1) {
document.addEventListener('DOMMouseScroll', wheelFun, false);
} else {
document.onmousewheel = wheelFun;
}
function wheelFun(event) {
var event = event || window.event;
var top = document.documentElement.scrollTop || document.body.scrollTop;
if (event.detail) {
if(event.detail > 0) {
console.log('向下');
} else {
console.log('向上');
}
} else if (event.wheelDelta) {
if (event.wheelDelta > 0) {
top--;
} else {
top++;
}
if (top > 200) {
box.style.display = 'block';
} else {
box.style.display = 'none';
}