fullpage实现单页面全屏网站

html源代码

<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>Apple Watch 宣传页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1,user-scalable=no">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.8.8/jquery.fullPage.min.css" />
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div id="fullPage">
        <div class="section section1">
            <h1>它,终于来了。</h1>
            <p>
                为了充分发挥体积小巧以及佩戴于手腕的优势,Apple Watch带来全新的科技和互动方式。它可以让你更快速便捷地完成一些在早已习惯的事,也可以实现过去根本无法企及的新功能,因此,这将会是焕然一新的使用体验,也将实现与你前所未有的贴近。
            </p>
            <a href="#">进一步了解</a>
        </div>
        <div class="section section2">
            <h1>真正与你贴近的个人设备</h1>
            <a href="#">进一步了解</a>
        </div>
        <div class="section section3">
            <h1>非同一般的精准计时</h1>
            <p>高级手表想来以计时精准为本,Apple Watch 更是如此。它与你的iPhone 配合使用,同全球标准时间的误差不超过50毫秒。而且,你可以对表盘进行个性化在设定,以更具个性化和意义的方式显示时间,使其更贴合你的生活和日程需要。</p>
            <a href="#">进一步了解计时</a>
        </div>
        <div class="section section4">
            <h1>在三个特点鲜明的系列中找到你的风格</h1>
            <div class="row">
                <div class="column">
                    <img src="img/primary_large_2x.jpg" class="primary">
                    <h4 class="primary"></h4>
                    <div class="intro">
                        <p>不锈钢或深空黑色不锈钢表壳,蓝宝石水晶镜面,搭配多款时尚表带。</p>
                        <a href="#" class="more">了解更多</a>
                    </div>
                </div>
                <div class="column">
                    <img src="img/sport_large_2x.jpg" class="sport">
                    <h4 class="sport"></h4>
                    <div class="intro">
                        <p>银色或深空灰色的阳极氧化铝金属表壳,强化Ion-X玻璃,搭配靓丽柔韧的表带。</p>
                        <a href="#" class="more">了解更多</a>
                    </div>
                </div>
                <div class="column">
                    <img src="img/edition_large_2x.jpg" class="edition">
                    <h4 class="edition"></h4>
                    <div class="intro">
                        <p>18K黄金或玫瑰金表壳,蓝宝石水晶镜面,搭配精雕细琢的表带及表扣。</p>
                        <a href="#" class="more">了解更多</a>
                    </div>
                </div>
            </div>
        </div>
    </div>

<script src="jquery-2.1.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.8.8/jquery.fullPage.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/move.js/0.5.0/move.min.js"></script>
<script src="app.js"></script>
</body>

</html>



css源代码
*{
    margin: 0;
    padding: 0;
}
body{
    font: 16px/1.8 "microsoft yahei",verdana;
}
.section{
    position: relative;
    background-color: #fff;
    overflow: hidden;
    text-align: center;
}
.section1{
    background: url("img/hero_sunset_large_2x.jpg") no-repeat center;
    background-size: cover;
}
.section1 h1{
    margin-top: 5%;
    color: #fff;
    font-weight: normal;
    font-size: 70px;
    opacity: 0.8;
}
.section1 p{
    margin: 5% auto 0;
    color: #fff;
    font-size: 18px;
    width: 70%;
    opacity: 0.6;
    margin-top: 800px;
}
.section1 a{
    display: block;
    margin: 5% auto 0;
    color: #ff9000;
    font-size: 18px;
    opacity: 0.9;
}
.section2{
    background: #f2f2f2 url("img/technology_hero_large_2x.jpg") no-repeat bottom;
    background-size: 100%;
}
.section2 h1{
    margin: 20px auto;
    color: #333;
    font-weight: normal;
    font-size: 60px;
}
.section2 a{
    display: block;
    margin: 20px auto 0;
    color: #08c;
    font-size: 18px;
}
.section3{
    background: #fff url("img/timekeeping_hero_large_2x.jpg") no-repeat center 300px;
    background-size: 50%;
}
.section3 h1{
    margin: 20px auto;
    color: #333;
    font-weight: normal;
    font-size: 40px;
    width: 60%;
    margin-left: -1500px;
}
.section3 p{
    margin: 20px auto 0;
    color: #333;
    font-size: 18px;
    width: 70%;
    margin-left: 1500px;
}
.section3 a{
    display: block;
    margin: 20px auto 0;
    color: #08c;
    font-size: 18px;
}
.section4{
    background: #fff;
}
.section4 h1{
    margin: 20px auto;
    color: #333;
    font-weight: normal;
    font-size: 30px;
}
.section4 .row{
    width: 95%;
    margin-left: 20px;
    color: #333;
    font-size: 18px;
}
.section4 .column{
    float: left;
    display: inline-block;
    width: 31%;
    margin: 10px;
    padding-bottom: 30px;
    background-color: #f2f2f2;
}
.section4 .column img{
    height: 300px;
    margin-top: 30px;
}
.section4 .column h4{
    margin: 20px auto;
}
.section4 .column h4.primary{
    background-image: url("img/logo_collection_primary.svg");
    background-size: 102px 22px;
    height: 22px;
    width: 102px;
}
.section4 .column h4.sport{
    background-image: url("img/logo_collection_sport.svg");
    background-size: 178px 22px;
    height: 22px;
    width: 178px;
}
.section4 .column h4.edition{
    background-image: url("img/logo_collection_edition.svg");
    background-size: 190px 22px;
    height: 22px;
    width: 190px;
}
.section4 .column p{
    margin: 10px auto;
    width: 90%;
    font-size: 16px;
}
.section4 .column a{
    display: block;
    margin: 10px auto 0;
    color: #08c;
    font-size: 16px;
}




js源代码
    // set()方法用于设置元素的css属性,两个参数css属性和属性值
    // scale()方法用于放大或缩小元素
    // rotate(deg)方法用于旋转元素
    // end()方法用于Move.js代码片段的结束,标志动画的结束,该方法触发动画的播放


    $(function(){
        $("#fullPage").fullpage({
            verticalCentered:false,
            anchors:['page1','page2','page3','page4'],
            continuousVertical:true,
            navigation:true,
            navigationTooltips:['它,终于来了。','真正与你贴近的个人设备','非同一般的精准计时','在三个特点鲜明的系列中找到你的风格'],
            afterLoad:function(link,index){
                switch(index){
                    case 1:
                        move(".section1 h1").scale(1.4).end();
                        move(".section1 p").set("margin-top","5%").end();
                        break;
                    case 2:
                        move(".section2 h1").scale(0.7).end();
                        break;
                    case 3:
                        move(".section3 h1").set("margin-left","20%").end();
                        move(".section3 p").set("margin-left","20%").end();
                        break;
                    case 4:
                        move(".section4 h1").scale(1.2).end();
                        move(".section4 img.primary").rotate(360).end(function(){
                            move(".section4 img.sport").rotate(360).end(function(){
                                move(".section4 img.edition").rotate(360).end(function(){
                                    move(".section4 h4.primary").scale(1.3).end(function(){
                                        move(".section4 h4.sport").scale(1.3).end(function(){
                                            move(".section4 h4.edition").scale(1.3).end();
                                        });
                                    });
                                });
                            });
                        });
                        break;
                    default:
                        break;
                }
            },
            onLeave:function(link,index){
                switch(index){
                    case 1:
                        move(".section1 h1").scale(1).end();
                        move(".section1 p").set("margin-top","800px").end();
                        break;
                    case 2:
                        move(".section2 h1").scale(1).end();
                        break;
                    case 3:
                        move(".section3 h1").set("margin-left","-1500px").end();
                        move(".section3 p").set("margin-left","1500px").end();
                        break;
                    case 4:
                        move(".section4 h1").scale(1).end();
                        move(".section4 img.primary").rotate(-360).end();
                        move(".section4 img.sport").rotate(-360).end();
                        move(".section4 img.edition").rotate(-360).end();
                        move(".section4 h4.primary").scale(1).end();
                        move(".section4 h4.sport").scale(1).end();
                        move(".section4 h4.edition").scale(1).end();
                        break;
                    default:
                        break;
                }
            },
            afterRender:function(){


            },
        });
    });

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值