时间:2022-12-31 浏览量: 收藏
网站前端设计中使用锚点链接来跳转到页面指定位置的时候,会生硬地立即跳转到指定位置,但是有些时候我们想要平滑地过渡到指定的位置,那么可以使用JQuery简单的实现平滑滚动效果。需要的页面引入以下代码即可:
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> //网站锚点链接平滑滚动 <script type="text/javascript"> $(function() { $('a[href*="#"]:not([href="#"])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html, body').animate({ scrollTop: target.offset().top }, 1000); return false; } } }); }); </script>
RELATED RECOMMEND
2022-12-31
1、通过PHPStudy中composer工具来安装thinkphp6.0:2、执行composer安装命令 composer create-project topthink/think tp6 6.0.*-dev:3、遇到安装失败,请更新镜像地址,
2022-12-31
在php程序判断客户端是通过电脑端还是手机端访问,以下是经过测试可行的函数function isMobile() { static $is_mobile = null; null === $is_mobile &&
2022-12-31
使用Teleport Pro软件的朋友应该知道他是一个离线浏览器,而他更大的作用则是可以用来下载别人的整站,软件的功能虽然好,但是却有一个很头疼的缺点,那就是下载下来 的网页它会在图片标签内插入tppabs标签以记录该图片的原始地址。因为这个标签不是合法标签,所以普通浏览器会忽略它。如图所示:其实可以在 DreamWeaver中使用正则表达式批量清除tppabs标签. 具体写法如下: 匹配tppabs标签: \btppabs="h[^"]*" 替换为 (空) 匹配javas...
Copyright © 2012-2024 世敏网络 版权所有 闽ICP备18026760号-1 闽公网安备 35020502000640号 网站地图 Sitemap 关键词聚合