本文实例为大家分享了vue实现全屏滚动效果(的具体代码,供大家参考,具体内容如下
是什么
网页的一个页面占据一屏的宽高,多个页面上下或者左右拼接在一起。当滑动鼠标滚轮,或点击导航按钮时,可以平滑到对应的页面。
此次只实现鼠标滚动
实现原理
使用mousewheel , DOMMouseScroll(火狐用)监听鼠标滚动事件,当鼠标上下的滚动的时候,当前的页面transformY(屏高)或者transformX(屏宽)
代码实现
HTML
1 2 3 4
JS
CSS
.fullPage{ height: 100%;//一定要设置,保证占满 overflow: hidden;//一定要设置,多余的先隐藏 background-color: rgb(189, 211, 186); } .fullPageContainer{ width: 100%; height: 100%; transition: all linear 0.5s; } .section { width: 100%; height: 100%; background-position: center center; background-repeat: no-repeat; } .section1 { background-color: rgb(189, 211, 186); background: url("./assets/intro-bg.jpg"); } .section1 .secction1-content { color: #fff; text-align: center; position: absolute; top: 40%; right: 0; left: 0; } .secction1-content h1 { font-size: 40px; padding-bottom: 30px; } .secction1-content p { font-size: 20px; } .section2 { background-color: rgb(44, 48, 43); } .section3 { background-color: rgb(116, 104, 109); } .section4 { background-color: rgb(201, 202, 157); }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



