隐藏a< div>当用JavaScript滚动到底部时

发布于 2025-01-28 03:38:29 字数 985 浏览 2 评论 0原文

几分钟前,我签署了我的问题,向您询问亲爱的社区。

不幸的是,我已经试图取得类似的问题,没有成功。

JavaScript不是我的强项,

如果它是一种移动设备,可以向他们显示这样的移动导航栏,那么我正在使用PHP检测到。 导航栏位于底部(并隐藏我的版权文本)。

if(isMobileDevice()){
require __DIR__. '/mobile-navbar.php';
}

我的移动 - navbar.php看起来如此

<div class="uver-mobile-navbar" id="mobile-navbar">
  <a href="#uver" class="active">uver</a>
  <a href="#uver">uver</a>
  <a href="#uver">uver</a>
  <a href="#uver">uver</a>
  <a href="#uver">uver</a>
</div>

,我的移动 - navbar.js看起来很问题,

document.onscroll = function() {
    if (window.innerHeight + window.scrollY > document.body.clientHeight) {
        document.getElementById('mobile-navbar').style.display='none';
    }else{
        document.getElementById('mobile-navbar').style.display='block';
    }
}

问题是,一旦我滚动,div就会消失。 当我滚动时,它不再出现了。

我提前感谢您的支持。

此致 里凡

I signed up a few minutes ago to ask my question to you dear community.

I have already tried to get ahead with similar questions, unfortunately without success.

Javascript is not my forte

I am detecting with php if it is a Mobile Device to show them a mobile navigationbar like this.
The navigation bar is positioned at the bottom (and hides my Copyright Text).

if(isMobileDevice()){
require __DIR__. '/mobile-navbar.php';
}

my mobile-navbar.php looks so

<div class="uver-mobile-navbar" id="mobile-navbar">
  <a href="#uver" class="active">uver</a>
  <a href="#uver">uver</a>
  <a href="#uver">uver</a>
  <a href="#uver">uver</a>
  <a href="#uver">uver</a>
</div>

and my mobile-navbar.js looks so

document.onscroll = function() {
    if (window.innerHeight + window.scrollY > document.body.clientHeight) {
        document.getElementById('mobile-navbar').style.display='none';
    }else{
        document.getElementById('mobile-navbar').style.display='block';
    }
}

The problem is that as soon as I scroll, the div disappears.
When I scroll up it doesn't appear anymore.

I thank you in advance for your support.

Best Regards
Ridvan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文