jQuery页面整屏滚动

11 篇文章 1 订阅
7 篇文章 0 订阅
本文介绍了如何使用jQuery库配合fullPage.js插件创建一个具有全屏滚动功能的页面,同时实现锚点导航,并在页面滚动到特定部分时动态隐藏或显示侧边菜单。
摘要由CSDN通过智能技术生成

效果展示

页面整屏滚动

jQuery页面整屏滚动

Html代码块

<div id="fullpage" class="fullpage-index">
	<!-- index01 -->
	<div class="indexitem index01 section" id="#page1">
		<img src="img/img01.jpg"/>
	</div>
	<!-- index02 -->
	<div class="indexitem index02 section" id="#page2">
		<img src="img/img08.jpg"/>
	</div>
	<!-- index03 -->
	<div class="indexitem index03 section" id="#page3">
		<img src="img/img03.jpg"/>
	</div>
	<!-- index04 -->
	<div class="indexitem index04 section" id="#page4">
		<img src="img/img07.jpg"/>
	</div>
	<!-- footer -->
	<div class="footer section fp-auto-height">
		<p>人生就是一列开往坟墓的列车,路途上会有很多站,<br/>很难有人可以自始至终陪着走完。<br/>当陪你的人要下车时,即使不舍也该心存感激,<br/>然后挥手道别。</p>
	</div>
	
</div>

<div class="dwlist" id="menu">
	<a data-menuanchor="page1" href="#page1" class="active"><p><span>不工作<br/>身上的魔法就会消失</span></p><strong></strong></a>
	<a data-menuanchor="page2" href="#page2"><p><span>不要忘记你的名字<br/>才能找到回家的路</span></p><strong></strong></a>
	<a data-menuanchor="page3" href="#page3"><p><span>曾经发生过的事情不可能忘记<br/>只不过是想不起而已</span></p><strong></strong></a>
	<a data-menuanchor="page4" href="#page4"><p><span>放心吧<br/>你一定可以做得到的</span></p><strong></strong></a>
</div>

css样式

/* 公用样式 */
html,body{width: 100%;height: 100%;position: relative;}
/* html{overflow-y: scroll;} */
*{margin:0; padding:0;color:#555; font-size:12px; font-family:"microsoft yahei"; line-height:1;font-weight: normal;letter-spacing: 0.3px;list-style:none;font-style: normal;font-size: 100%;}
a,li,ul{list-style:none;text-decoration:none}
ul li a{font-size:16px;color:#333}
body{width:100%;height:100%;position:relative}

.indexitem img{width: 100%;height: 100%;object-fit: cover;}

/* footer */
.footer{width: 100%;background-color: #000;}
.footer p{font-size: 16px;color: #fff;text-align: center;line-height: 30px;padding: 50px 0;}
.fp-auto-height.fp-section,.fp-auto-height .fp-slide,.fp-auto-height .fp-tableCell{ height: auto !important;}

/* dwlist */
.dwlist{position: fixed;right: 90px;bottom: 30%;z-index: 9;overflow:hidden;padding:10px;}
.dwlist a{display: flex;display: -webkit-flex;align-items: center;-webkit-align-items: center;text-align: right;justify-content: flex-end;-webkit-justify-content: flex-end;opacity:0.5;filter:drop-shadow(0px 1px 3px #656798);margin-bottom: 10px;}
.dwlist a p{font-size: 12px;color: #fff;font-family: Arial;text-transform:uppercase;line-height:18px;overflow:hidden;}
.dwlist a p span{transform:translateX(100%);transition:all .3s;opacity: 0;display:block;color: #fff;font-size: 16px;line-height:24px;}
.dwlist a strong{display: block;width: 8px;height: 50px;box-sizing: border-box;border: 1px solid #fff;transition: all .3s;margin-left: 5px;}
.dwlist a.active{opacity: 1;}
.dwlist a.active strong{background-color: #fff;height: 80px;}
.dwlist a:last-child strong{margin-bottom: 0;}
.dwlist a.active p span{opacity: 1;transform:none;}
.dwlist:hover{opacity:1;}
.dwlist:hover a span{transform: none;opacity:1;}
.dwlist.hide{opacity: 0;visibility: hidden;}

js代码块

<script src="js/jquery.js"></script>
<script src="js/fullPage.js"></script>
<script>
	$('#fullpage').fullpage({
		'navigation': true,
		menu: '#menu',
		anchors: ['page1', 'page2', 'page3', 'page4'],
		afterLoad: function(anchorLink, index){
			var loadedSection = $(this);
			//using index
			console.log(index)
			if(index == 5){
				$(".dwlist").addClass('hide')
			}else{
				$(".dwlist").removeClass('hide')
			}
		}, 
	});
</script>
  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值