这次给大家带来如何使用jquery制作置顶菜单的实战案例,下面是详细分析,一起来看一下吧。
jquery制作置顶菜单
nbsp;html>06-置顶菜单 $(function(){ $(window).scroll(function() { var nowTop = $(document).scrollTop(); if (nowTop>200) { // 注意是 “,” $('.menu').css({ position:'fixed', top:0, // 定位 一半 left:'50%', marginLeft:-480, }) $('.menu_pos').show(); }else{ $('.menu').css({ // 对原来的样式进行覆盖 position:'static', marginLeft:'auto', }) $('.menu_pos').hide(); } }); }) body{margin:0px;} .logo_bar{ width:960px; height:200px; background-color:#f0f0f0; margin:0 auto; } .menu,.menu_pos{ width:960px; height:50px; margin:0 auto; background-color:gold; text-align:center; line-height:50px; } .menu_pos{ display:none; } .down_con{ width:960px; height:1800px; margin:0 auto; } .down_con p{ margin-top:100px; text-align:center; } .totop{ width:50px; height:50px; background:url(images/up.png) center center no-repeat #000; border-radius:50%; position:fixed; right:50px; bottom:50px; display:none; }顶部logo
置顶菜单
网站主内容
网站主内容
网站主内容
网站主内容
网站主内容
登录后复制登录后复制
jquery制作置顶菜单
nbsp;html>06-置顶菜单 $(function(){ $(window).scroll(function() { var nowTop = $(document).scrollTop(); if (nowTop>200) { // 注意是 “,” $('.menu').css({ position:'fixed', top:0, // 定位 一半 left:'50%', marginLeft:-480, }) $('.menu_pos').show(); }else{ $('.menu').css({ // 对原来的样式进行覆盖 position:'static', marginLeft:'auto', }) $('.menu_pos').hide(); } }); }) body{margin:0px;} .logo_bar{ width:960px; height:200px; background-color:#f0f0f0; margin:0 auto; } .menu,.menu_pos{ width:960px; height:50px; margin:0 auto; background-color:gold; text-align:center; line-height:50px; } .menu_pos{ display:none; } .down_con{ width:960px; height:1800px; margin:0 auto; } .down_con p{ margin-top:100px; text-align:center; } .totop{ width:50px; height:50px; background:url(images/up.png) center center no-repeat #000; border-radius:50%; position:fixed; right:50px; bottom:50px; display:none; }顶部logo
置顶菜单
网站主内容
网站主内容
网站主内容
网站主内容
网站主内容
登录后复制登录后复制
以上就是如何使用jquery制作置顶菜单的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2781466.html