仿360全屏滚动
2016-10-31 17:56
260 查看
<!DOCTYPE HTML> <html> <head> <title>仿360全屏切换</title> <meta charset="utf-8"> <meta name="Author" content="Barnett"> <style type='text/css'> *{ margin:0; padding:0;} html,body{ height:100%; } a img{ border:none; } li{ list-style:none; } body{ overflow:hidden; } #bg{ height:100%; } #bg div{ height:100%; background-position:center; background-attachment:fixed; } #header{ width:100%; height:47px; position:fixed; top:27px; } #header .logo{ width:226px; height:47px; margin-left:50px; float:left; } #header .nav{ width:400px; height:47px; float:right; margin-right:50px; position:relative; } #header .nav ul{ height:47px; position:relative; z-index:1; } #header .nav ul li{ float:left; font-size:14px; line-height:47px; margin-left:53px; } #header .nav ul li a{ color:#fff; color:rgba(255,255,255,0.8); text-shadow:4px 3px 10px #000; text-decoration:none; font-family:'aaaaa','Microsoft yahei','楷体'; } #header .nav ul li.on a{ color:#fff; } #border{ width:56px; height:30px; border:1px solid #fff; border:1px solid rgba(255,255,255,0.7); border-radius:16px; position:absolute; top:8px; left:38px; } #slide{ width:100px; height:330px; position:fixed; top:35%; left:50px; background:url(img/nav.png) no-repeat; } #slide ul li{ font-size:12px; color:#fff; color:rgba(255,255,255,0.8); font-family:'Microsoft yahei','楷体'; padding-left:50px; line-height:21px; margin-top:6px; margin-bottom:56px; cursor:pointer; } #slide ul li.on{ background:url(img/nav_cho.png) no-repeat; } </style> <script type="text/javascript" src="js/jquery-1.12.1.min.js"></script> <script type="text/javascript" src="js/jquery.mousewheel.js"></script> </head> <body> <div id="header"> <div class="logo"> <a href=""><img src="img/logo.png" /></a> </div> <div class="nav"> <ul> <li class="on"><a href="">首页</a></li> <li><a href="">常见问题</a></li> <li><a href="">论坛</a></li> <li><a href="">360首页>></a></li> </ul> <div id="border"></div> </div> </div> <div id="bg"> <div class='bg1' style="background-image:url(img/1.jpg);"></div> <div class='bg2' style="background-image:url(img/2.jpg);"></div> <div class='bg3' style="background-image:url(img/3.jpg);"></div> <div class='bg4' style="background-image:url(img/4.jpg);"></div> </div> <div id="slide"> <ul> <li class="on">安全换机</li> <li>无网对传</li> <li>隐私粉碎</li> <li>一键转移</li> </ul> </div> <script type="text/javascript"> window.onload = function(){ $(document).scrollTop(0); } var $navLi = $('.nav ul li'); var $border = $('#border'); var $nav = $('.nav'); var $slideLi = $('#slide ul li'); var index = 0; $navLi.mouseenter(function(){ var thisWidth = $(this).width(); var thisLeft = $(this).position().left; $(this).addClass('on').siblings().removeClass('on'); $border.stop(true).animate({ left : thisLeft+38 + 'px', width : thisWidth+28 + 'px' },300); }); $nav.mouseleave(function(){ $navLi.eq(0).addClass('on').siblings().removeClass('on'); $border.stop(true).animate({ left : '38px', width : '56px' },300); }); $slideLi.click(function(){ index = $(this).index(); wheel(); }); $(document).mousewheel(function(e,d){ if ( d < 0 ) { index ++; index %= $slideLi.length } else { index --; if(index<0)index=$slideLi.length-1; } wheel(); }); $(window).resize(function(){ var windowH = $(window).height(); $(document).scrollTop( index * windowH ); }); function wheel(){ $slideLi.eq(index).addClass('on').siblings().removeClass('on'); var windowH = $(window).height(); $('body,html').stop(true).animate({ scrollTop : index * windowH },500); }; </script> </body> </html>
相关文章推荐
- jQuery全屏滚动插件FullPage.js中文帮助文档API
- 鼠标拖动控制页面滚动 (可运用于全屏触摸设备)
- jQuery----全屏滚动插件fullPage
- 响应式的无限滚动全屏dribbble作品集布局展示效果
- IOS_实现tableview向上滚动全屏效果与点击展开动画
- pagePiling.js - 创建漂亮的全屏滚动效果
- 全屏滚动的实现
- 用window.scrollTo实现有滚动条的全屏滚动
- FullPage.js – 轻松实现全屏滚动(单页网站)效果
- js实现的鼠标滚轮滚动切换页面效果(类似360默认页面滚动切换效果)
- jQuery全屏滚动插件fullPage.js
- Javascript 实现全屏滚动实例代码
- fullPage 全屏滚动【上下滚动】效果
- 《fullPage.js》创建全屏滚动的网站
- 全屏滚动
- 全屏滚动实现之fullPage.js(二)
- scrollify - 滚动条方式的全屏滚动
- js修炼——手写全屏滚动插件
- javascript 全屏显示和iframe滚动
- 响应式的无限滚动全屏dribbble作品集布局展示效果