如何缩小滚动时的导航条?

问题描述 投票:0回答:1

我的网站使用的是Fullpage.js。在使用Fullpage.js的情况下,收缩导航条的脚本无法工作。当我试着在没有Fullpage.js的情况下运行脚本时,它可以完美地工作。

导航条的CSS

#navbar {
    position: fixed;
    z-index: 999;
    width: 100%;
    background-color: #212F56;
    transition: 0.5s;
    padding: 50px 10px;
    overflow: auto;
    top: 0;
}

缩小导航条的脚本

<script>
    window.onscroll = function()
    {
        scrollFunction()
    };
    function scrollFunction() 
        {
        if (document.body.scrollTop > 10 || document.documentElement.scrollTop > 10)
            {
            document.getElementById("navbar").style.padding = "5px 10px";
            }
        else {
            document.getElementById("navbar").style.padding = "50px 10px";
                }
            }
</script>
javascript html css navbar fullpage.js
1个回答
-1
投票

我让它工作了,是fullpage.js库的问题,它在控制台中也给出了一个错误代码。

"fullPage: Fullpage.js版本3已经改变了它的授权,改为GPLv3,它需要一个 licenseKey 选项。在这里阅读:"和 "fullPage.js"。https:/github.comalvarotrigofullPage.js#options。."

下面是codepen上的工作缩小导航条。codepen

我刚刚删除了你的剧本标签

<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.0.8/fullpage.min.js" integrity="sha256-caNcSA0LvOCX90PTuEbwl+V09xPMca13CJUasl+VCtk=" crossorigin="anonymous">
</script>
© www.soinside.com 2019 - 2024. All rights reserved.