fullpage的使用

fullPage简介

fullPage.js是一个基于jQuery的全屏滚动插件,它能够很方便,很轻松的制作出全屏网站

主要功能:

支持鼠标滚动,多个回调函数,支持手机,平板触摸事件,支持css3动画,窗口缩放时自动调整,可设置滚动宽度,背景颜色,滚动速度,循环选项,毁掉,文本对齐方式等

引入基本文件
我引用的是Bootcdn的远程文件,你们也也可以把文件下载到本地来引用,这样可以更快些,这里要注意的是Juqery的引用一定要在jquery.fullpage上面,因为fullpage是建立在jquery基础上的。

<link href="https://cdn.bootcss.com/fullPage.js/2.9.5/jquery.fullpage.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
<script src="https://cdn.bootcss.com/fullPage.js/2.9.5/jquery.fullpage.js"></script>

编写HTML结构

<div id="fullpage">
<div class="section" id="section0">
<h1>这是第一屏</h1>
</div>
<div class="section" id="section1">
<h1>这是第二屏</h1>
</div>
<div class="section" id="section2">
<h1>这是第三屏</h1>
</div>
</div>

 

Js激活插件

<script>
$(function() {
$('#fullpage').fullpage();
});
</script>

到这里就已经ok了,一个全屏滚动的页面就做好了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在 Vue.js 项目中使用 fullpage.js,可以使用 Vue-fullpage.js 插件。下面是一个简单的使用示例: 1. 安装 Vue-fullpage.js 使用 npm 或 yarn 安装 Vue-fullpage.js: ``` npm install vue-fullpage.js ``` 或者 ``` yarn add vue-fullpage.js ``` 2. 在 Vue.js 项目中引入 Vue-fullpage.js 在 main.js 中引入 Vue-fullpage.js: ```javascript import Vue from 'vue' import VueFullpage from 'vue-fullpage.js' Vue.use(VueFullpage) ``` 3. 创建 fullpage 组件 在组件中使用 `<vue-fullpage>` 标签创建 fullpage 组件,然后在组件的 data 中定义页面: ```vue <template> <div> <vue-fullpage :options="options"> <div class="section"> <h1>Page 1</h1> </div> <div class="section"> <h1>Page 2</h1> </div> <div class="section"> <h1>Page 3</h1> </div> </vue-fullpage> </div> </template> <script> export default { data() { return { options: { sectionsColor: ['#f2f2f2', '#4BBFC3', '#7BAABE'] } } } } </script> ``` 在这个示例中,我们创建了一个 fullpage 组件,定义了三个页面,每个页面都是一个 `<div>` 元素,并设置了页面的颜色。 4. 配置和使用 fullpage.js 可以在组件的 data 中设置 fullpage.js 的配置参数,例如页面滚动的速度、页面的动画效果、是否循环滚动等。可以在 options 对象中设置 fullpage.js 的配置参数,例如: ```javascript data() { return { options: { sectionsColor: ['#f2f2f2', '#4BBFC3', '#7BAABE'], scrollingSpeed: 1000, easingcss3: 'cubic-bezier(0.175, 0.885, 0.32, 1.275)', loopBottom: true, loopTop: true, anchors: ['page1', 'page2', 'page3'] } } } ``` 可以使用 fullpage.js 提供的钩子函数,例如: ```javascript data() { return { options: { afterLoad: function(origin, destination, direction) { console.log('afterLoad', origin.index, destination.index, direction) }, onLeave: function(origin, destination, direction) { console.log('onLeave', origin.index, destination.index, direction) } } } } ``` 在这个示例中,我们定义了 `afterLoad` 和 `onLeave` 两个钩子函数,分别在页面滚动到新页面之后和离开当前页面之前执行。这些钩子函数可以用来执行一些特定的操作,例如修改页面标题、添加动画效果等。 这样就可以在 Vue.js 项目中使用 fullpage.js 了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值