SOURCE

console 命令行工具 X clear

                    
>
console
var list = document.getElementsByClassName("list")[0]
window.onscroll = function(){
    console.log(window.pageYOffset)
    if(window.pageYOffset>500){
        list.style.height = "0px"
    }else{
        list.style.height = "40px"
    }
}
<div class="list">

</div>
.list{
    width: 100%;
    height: 40px;
    background: red;
    transform: 0.5s;
    position: fixed;
    top: 0;
}
body{
    margin: 0;
    padding: 0;
    height: 3000px;
}