主页平滑滚动效果

此HTML代码展示了如何使用fullPage.js库创建一个具有全屏滚动效果的页面,包括不同颜色背景的三个部分。页面还包含一个固定位置的菜单,可与滚动部分联动。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Page Scroll Effect</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.min.css">
    <style>
        /* 自定义样式 */
        .section {
            text-align: center;
            padding: 50px;
            color: #fff;
        }
        #menu {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 9999;
        }
        #menu li {
            display: inline-block;
            margin: 0 10px;
            cursor: pointer;
            color: #fff;
        }
    </style>
</head>
<body>
<div id="fullpage">
    <div class="section" data-anchor="section1" style="background-color: #f2f2f2;">
        <h1>Section 1</h1>
    </div>
    <div class="section" data-anchor="section2" style="background-color: #4BBFC3;">
        <h1>Section 2</h1>
    </div>
    <div class="section" data-anchor="section3" style="background-color: #7BAABE;">
        <h1>Section 3</h1>
    </div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.1.2/fullpage.min.js"></script>
<script>
    $(document).ready(function() {
        $('#fullpage').fullpage({
            sectionsColor: ['#f2f2f2', '#4BBFC3', '#7BAABE'],
            scrollingSpeed: 1000,
            menu: '#menu',
            afterLoad: function(origin, destination, direction) {
                // 滚动到某个部分后的操作
            }
        });
    });
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值