这篇文章主要介绍了jquery实现滑动页面固定顶部显示,还可根据显示位置消失与替换对应的当前显示项,具有一定参考借鉴价值,需要的朋友可以参考下
本文实例讲述了jQuery实现滑动页面固定顶部显示(可根据显示位置消失与替换)。分享给大家供大家参考,具体如下:
这里介绍的jQuery拉动页面固定顶部显示,及自动消失效果,可能ie浏览器下有问题,不过火狐什么的都可以运行看效果,一个简单的网页特效,也是很常用的“回到顶部”效果,有兴趣的看一下。
运行效果截图如下:
具体代码如下:
nbsp;html>回到顶部:哭泣的小丑 html, body, p, span, applet, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,a, abbr, acronym, address, big, cite, code,del, dfn, em, img, ins, kbd, q, s, samp,small, strike, strong, sub, sup, tt, var,b, u, i, center,dl, dt, dd, ol, ul, li,fieldset, form, label, legend, input,table, caption, tbody, tfoot, thead, tr, th, td,article, aside, canvas, details, embed,figure, figcaption, footer, header, hgroup,menu, nav, output, ruby, section, summary,time, mark, audio, video {margin: 0;padding: 0;border: 0;font-size: 100%;}article, aside, details, figcaption, figure,footer, header, hgroup, menu, nav, section {display: block;float:left;}select, input, button,button img, label {vertical-align: middle;}body {font:normal 12px/1.5 "Microsoft Yahei","微软雅黑",Tahoma,Arial,Helvetica,STHeiti; webkit-font-smoothing:antialiased;-moz-font-smoothing: subpixel-antialiased; color:#666;}ol, ul {list-style: none;}blockquote, q {quotes: none;}blockquote:before, blockquote:after,q:before, q:after {content: '';content: none;}table {border-collapse: collapse;border-spacing: 0;}em {font-style: normal}select, input, button, button img, label {vertical-align:middle;}input {font-family:"Microsoft Yahei","微软雅黑";webkit-font-smoothing:antialiased;-moz-font-smoothing: subpixel-antialiased}input, input:focus, button, button:focus, select,textarea, textarea:focus {outline:none; -moz-outline:none; -webkit-outline:none; }input:focus { outline:none; -moz-outline:none; -webkit-outline:none; }textarea {resize:none;}a {color:#666; text-decoration:none;} a:hover {text-decoration:underline;}a:focus {outline:none; -moz-outline:none;-webkit-outline:none;}body {min-width: 960px;}body{background:#e7e7e7;}.clearfix:before, .clearfix:after, .container_24:before, .container_24:after { content: '.'; display: block; overflow: hidden; visibility: hidden; font-size: 0; line-height: 0; width: 0; height: 0;}.clearfix:after, .container_24:after { clear: both; }.Xc_main{width:750px;margin:0 auto;position:relative;}.Xc_left{float:left;}.Xc_left h1{font-size:24px;padding-top:25px;}.Xc_right{float:right;width:600px;}.Xc_right .Xc_list{margin:10px 0 10px 0;}.Xc_list_top,.Xc_list_main{background:#fff;padding:10px;border:1px solid #ccc;}.Xc_list_top{margin-bottom:10px;}.Xc_gg{width:90px;height:90px;border:1px solid #ccc;background:#fff;text-align:center;}.Xc_bottom{height:650px;background:#fff;padding:10px;border:1px solid #ccc;position:relative;}$(function () { $(".Xc_list_top").css("width",$(".Xc_list_main").width()); var resetRightPanelPostion = function () { var msie6 = $.browser.msie && $.browser.version == '6.0' && $.browser.version < 7; if ($.browser.safari) { bodyelem = $("body"); } else { bodyelem = $("html,body"); } var bodyTop = bodyelem.scrollTop(); var top = $(".Xc_left").offset().top; //var t = $("#public_footer").offset().top; var t = $("#footerDestinationBox").offset().top; //var bottom = $("#footerDestinationBox").offset().top; for(var i = 0 ; i = top && ((bodyTop + $(".Xc_left").outerHeight()) = t) { $(".Xc_gg").removeClass('fixed').css({ "position": "absolute", "top": t - $(".Xc_gg").outerHeight() + "px" }); } else { $(".Xc_gg").css({ "position": "fixed", "top": 0 }); } } } else { if (!msie6) { $(".Xc_gg").css({ "position": "static" }); } } if(bodyTop>$(".Xc_list").eq(i).offset().top){ $(".Xc_list_top").eq(i).css({position:"absolute",top:top-168}); } if(bodyTop>$(".Xc_list").eq(i).offset().top){ $(".Xc_list_top").eq(i).css({position:"fixed",top:0}); } if(bodyTop<=$(".Xc_list").eq(i).offset().top){ $(".Xc_list_top").eq(i).css({position:"static",top:0}); } } }; window.onload = function () { if ($(".Xc_gg").length) { resetRightPanelPostion(); $(window).scroll(function () { resetRightPanelPostion(); }); } }})
小丑
Q群:150508281
top 1
top 2
top 3
top 4
top 5
top 6
by 蓝色理想 @哭泣的小丑
登录后复制
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
关于jQuery插件Timelinr 实现时间轴特效
JS实现移动端向左滑动出现删除按钮的功能
以上就是jQuery实现滑动页面固定顶部显示的功能的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2748605.html