fullpage.js自定义导航

       我们都知道怎么使用fullpage.js。主要是下面的命令来控制导航的

$(function(){
    $('#fullpage').fullpage({
        //默认navigation: false //不显示项目导航 通过下面这句可以控制将导航加入到页面上
         'navigation': true,
    })
})

      但是,如果我们想要自己定义导航呢?不使用他提供的一些css属性,自己写好html和css基本样式,通过滚动显示页码?搜索大量资料,看到以下博客,通过该方法确实可以实现的,即使不指定css3动画翻页也可以。【在火狐、ie7-9、谷歌、360下调试】360的兼容模式不行。

      演示地址:    http://runjs.cn/detail/x1jdppsz

      点击演示屏右下角的全屏查看,可以更直观的查看效果,点击查看源码可以查看我demo是怎么实现的

      原博客地址:http://blog.163.com/hongshaoguoguo@126/blog/static/18046981201481504334743/


      具体做法如下:

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
	
    <link href="style/jquery.fullPage.css" rel="stylesheet" type="text/css" />
    <link href="style/base.css" rel="stylesheet" type="text/css" />
	<link href="style/index.css" rel="stylesheet" type="text/css" />
    
    <script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/jquery.fullPage.min.js"></script>
</head>

<body>
	
<div id="superContainer">
	<div class="fp-section" style=" background:#069;"></div>
    <div class="fp-section" style=" background:#099"></div>
    <div class="fp-section" style=" background:#963;"></div>
    <div class="fp-section" style=" background:#633;"></div>
</div>
<div id="menu" class="right">
	<ul>
    	<li data-menuanchor="page1">
        	<a href="#page1"></a> 
        </li>
        <li data-menuanchor="page2">
        	<a href="#page2"></a> 
        </li>
        <li data-menuanchor="page3">
        	<a href="#page3"></a>       
        </li>
        <li data-menuanchor="page4">
        	<a href="#page4"></a> 
        </li>
    </ul>
</div>

</body>
</html>

<script>	
$(function(){
    $('#superContainer').fullpage({
	slidesColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', '#f90'],
        anchors: ['page1', 'page2', 'page3', 'page4'],
        css3: false,
        menu: "#menu"
	});
});
</script>


@charset "utf-8";
/* CSS Document */


.wrapper{ width:660px; height:200px; margin:0 auto; padding-top:60px; position:relative; }
.wrapper div{ width:200px; height:200px; line-height:200px; font-size:24px; color:#fff; text-align:center; }

.bor02:hover{ width:300px; height:300px; transform:rotate(360deg); background:#099; left:150px; top:30px;}

#menu{ position: fixed; top: 50%; margin-top: -32px;}
#menu.right{ right: 10px;}
#menu ul li{ width: 10px; height: 10px; background: #ccc; margin:10px; border-radius: 10px;}
#menu li.active{ background:#000; }



      当然,首先是要下载fullpage.js插件,引入到自己的项目里头。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值