jquery+html+css坐标描点平滑滚动返回顶部和底部代码
效果演示:
HTML代码:
<script type="text/javascript" src="https://www.yizhanzzw.com/wp-content/themes/zibll/js/libs/jquery.min.js?ver=7.1"></script><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="zhengwen">正文</div><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="demo bottom"></div><div class="location"><p class="dingbutop">滑倒顶部</p><p class="chanpin">产品介绍</p><p class="dibu">滑到底部</p></div><script type="text/javascript" src="https://www.yizhanzzw.com/wp-content/themes/zibll/js/libs/jquery.min.js?ver=7.1"></script> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="zhengwen">正文</div> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="demo bottom"></div> <div class="location"> <p class="dingbutop">滑倒顶部</p> <p class="chanpin">产品介绍</p> <p class="dibu">滑到底部</p> </div>
<script type="text/javascript" src="https://www.yizhanzzw.com/wp-content/themes/zibll/js/libs/jquery.min.js?ver=7.1"></script>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="zhengwen">正文</div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo bottom"></div>
<div class="location">
<p class="dingbutop">滑倒顶部</p>
<p class="chanpin">产品介绍</p>
<p class="dibu">滑到底部</p>
</div>CSS代码:
<style>.demo{ height:200px; width:100%; background:#55aaff; margin:10px 0;}.location{ position:fixed; right:0; bottom:10px; width:60px; background:#0055ff; padding:5px; cursor:pointer;color:#ffffff};</style><style> .demo{ height:200px; width:100%; background:#55aaff; margin:10px 0;} .location{ position:fixed; right:0; bottom:10px; width:60px; background:#0055ff; padding:5px; cursor:pointer;color:#ffffff}; </style>
<style>
.demo{ height:200px; width:100%; background:#55aaff; margin:10px 0;}
.location{ position:fixed; right:0; bottom:10px; width:60px; background:#0055ff; padding:5px; cursor:pointer;color:#ffffff};
</style>jquery代码:
<script type="text/javascript">jQuery(document).ready(function($){$(window).load(function(){$('.dingbutop').click(function(){$('html,body').animate({scrollTop: '0px'}, 1000);//数字越大滑动越慢});$('.chanpin').click(function(){$('html,body').animate({scrollTop:$('.zhengwen').offset().top}, 1000);//数字越大滚动动越慢});$('.dibu').click(function(){$('html,body').animate({scrollTop:$('.bottom').offset().top}, 1000);}); }); //数字越大滑动越慢});</script><script type="text/javascript"> jQuery(document).ready( function($){ $(window).load(function(){ $('.dingbutop').click( function(){ $('html,body').animate({scrollTop: '0px'}, 1000);//数字越大滑动越慢 }); $('.chanpin').click(function(){$('html,body').animate({scrollTop:$('.zhengwen').offset().top}, 1000);//数字越大滚动动越慢 }); $('.dibu').click(function(){$('html,body').animate({scrollTop:$('.bottom').offset().top}, 1000);}); }); //数字越大滑动越慢 }); </script>
<script type="text/javascript">
jQuery(document).ready(
function($){
$(window).load(function(){
$('.dingbutop').click(
function(){
$('html,body').animate({scrollTop: '0px'}, 1000);//数字越大滑动越慢
});
$('.chanpin').click(function(){$('html,body').animate({scrollTop:$('.zhengwen').offset().top}, 1000);//数字越大滚动动越慢
});
$('.dibu').click(function(){$('html,body').animate({scrollTop:$('.bottom').offset().top}, 1000);}); }); //数字越大滑动越慢
});
</script>完整代码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>js平滑滚动到描点指定地方+返回顶部返回底部</title><script type="text/javascript" src="https://www.yizhanzzw.com/wp-content/themes/zibll/js/libs/jquery.min.js?ver=7.1"></script><style>.demo{ height:200px; width:100%; background:#55aaff; margin:10px 0;}.location{ position:fixed; right:0; bottom:10px; width:60px; background:#0055ff; padding:5px; cursor:pointer;color:#ffffff};</style></head><body><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="zhengwen">正文</div><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="demo"></div><div class="demo bottom"></div><div class="location"><p class="dingbutop">滑倒顶部</p><p class="chanpin">产品介绍</p><p class="dibu">滑到底部</p></div><script type="text/javascript">jQuery(document).ready(function($){$(window).load(function(){$('.dingbutop').click(function(){$('html,body').animate({scrollTop: '0px'}, 1000);//数字越大滑动越慢});$('.chanpin').click(function(){$('html,body').animate({scrollTop:$('.zhengwen').offset().top}, 1000);//数字越大滚动动越慢});$('.dibu').click(function(){$('html,body').animate({scrollTop:$('.bottom').offset().top}, 1000);}); }); //数字越大滑动越慢});</script></body></html><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>js平滑滚动到描点指定地方+返回顶部返回底部</title> <script type="text/javascript" src="https://www.yizhanzzw.com/wp-content/themes/zibll/js/libs/jquery.min.js?ver=7.1"></script> <style> .demo{ height:200px; width:100%; background:#55aaff; margin:10px 0;} .location{ position:fixed; right:0; bottom:10px; width:60px; background:#0055ff; padding:5px; cursor:pointer;color:#ffffff}; </style> </head> <body> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="zhengwen">正文</div> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="demo"></div> <div class="demo bottom"></div> <div class="location"> <p class="dingbutop">滑倒顶部</p> <p class="chanpin">产品介绍</p> <p class="dibu">滑到底部</p> </div> <script type="text/javascript"> jQuery(document).ready( function($){ $(window).load(function(){ $('.dingbutop').click( function(){ $('html,body').animate({scrollTop: '0px'}, 1000);//数字越大滑动越慢 }); $('.chanpin').click(function(){$('html,body').animate({scrollTop:$('.zhengwen').offset().top}, 1000);//数字越大滚动动越慢 }); $('.dibu').click(function(){$('html,body').animate({scrollTop:$('.bottom').offset().top}, 1000);}); }); //数字越大滑动越慢 }); </script> </body> </html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>js平滑滚动到描点指定地方+返回顶部返回底部</title>
<script type="text/javascript" src="https://www.yizhanzzw.com/wp-content/themes/zibll/js/libs/jquery.min.js?ver=7.1"></script>
<style>
.demo{ height:200px; width:100%; background:#55aaff; margin:10px 0;}
.location{ position:fixed; right:0; bottom:10px; width:60px; background:#0055ff; padding:5px; cursor:pointer;color:#ffffff};
</style>
</head>
<body>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="zhengwen">正文</div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo"></div>
<div class="demo bottom"></div>
<div class="location">
<p class="dingbutop">滑倒顶部</p>
<p class="chanpin">产品介绍</p>
<p class="dibu">滑到底部</p>
</div>
<script type="text/javascript">
jQuery(document).ready(
function($){
$(window).load(function(){
$('.dingbutop').click(
function(){
$('html,body').animate({scrollTop: '0px'}, 1000);//数字越大滑动越慢
});
$('.chanpin').click(function(){$('html,body').animate({scrollTop:$('.zhengwen').offset().top}, 1000);//数字越大滚动动越慢
});
$('.dibu').click(function(){$('html,body').animate({scrollTop:$('.bottom').offset().top}, 1000);}); }); //数字越大滑动越慢
});
</script>
</body>
</html>修改说明:
- 代码中的jquery.js引用的是本站的链接,可不必修改,也可自行下载引用。
- 修改class值的时候注意要和下面jquery的值对应,否则不会生效。
1.本站资源都是白菜价出售,同样的东西,我们不卖几百,也不卖几十,甚至才卖几块钱,一个永久会员能下载全站100%源码了,所以单独购买也好,会员也好均不提供相关技术服务。
2.如果源码下载地址失效请/联系站长QQ进行补发。
3.本站所有资源仅用于学习及研究使用,请必须在24小时内删除所下载资源,切勿用于商业用途,否则由此引发的法律纠纷及连带责任本站和发布者概不承担。资源除标明原创外均来自网络整理,版权归原作者或本站特约原创作者所有,如侵犯到您权益请联系本站删除!
4.本站站内提供的所有可下载资源(软件等等)本站保证未做任何负面改动(不包含修复bug和完善功能等正面优化或二次开发);但本网站不能保证资源的准确性、安全性和完整性,用户下载后自行斟酌,我们以交流学习为目的,并不是所有的源码都100%无错或无bug;同时本站用户必须明白,【源码源码ui网】对提供下载的软件等不拥有任何权利(本站原创和特约原创作者除外),其版权归该资源的合法拥有者所有。
5.请您认真阅读上述内容,购买即以为着您同意上述内容。
源码UI网 » jquery+html+css坐标描点平滑滚动返回顶部和底部代码