<html>
<head>
    <title>test</title>
</head>
<body>
    <div style="position: fixed; height: 200px; background: red; width: 100%; display: none" id="topbar"></div>
    <div style="height: 3000px;">content</div>
</body>
<script type="text/javascript">
    window.onscroll = function () {
        var top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
        var node = document.getElementById('topbar');
        if (top > 500) {//500就是滚动条滚动到的位置,大于500才显示
            node.style.display = 'block';
        } else {
            node.style.display = 'none';
        }
    }
</script>
</html>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
  • 2021-08-27
  • 2021-10-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案