首页 / 知识
HTML网页设计中的锚点滚动代码
2023-04-11 15:57:00

<!DOCTYPE html> <html> <head> <metacharset="UTF-8"> <metaname="viewport"content="width=device-width, initial-scale=1.0"> <metahttp-equiv="X-UA-Compatible"content="ie=edge"> <title>js锚点滚动效果</title> <style> ul>li{float: left;margin: 10px ;} .clearfix:after{display:block;clear:both;content:"";visibility:hidden;height:0} .clearfix{zoom:1} .step{width:80%;height:1300px;border:10pxsolidred;margin:0auto;} </style> </head> <body> <ulclass="clearfix"> <li><ahref="#step1">#step1</a></li> <li><ahref="#step2">#step2</a></li> <li><ahref="#step3">#step3</a></li> </ul> <div> <divid="step1"class="step">step1</div> <divid="step2"class="step">step2</div> <divid="step3"class="step">step3</div> </div> </body> <scriptsrc="http://libs.baidu.com/jquery/1.8.3/jquery.min.js"></script> <script> //页面锚点滚动js $('a[href*=#],area[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) { vartargetOffset=$target.offset.top; $('html,body').animate({ scrollTop: targetOffset }, 1000); returnfalse; } } }); //页面锚点滚动js结束 </script> </html> |
最新内容
相关内容
python如何replace(替换)多个字符?
python如何replace(替换)多个字符?,培训,字符,字符串,方法,正则,括号,数组,函数,定义,以上,python中使用replace替换多个字符的方法:1、使用repython什么时候加self?
python什么时候加self?,培训,变量,方法,作用,参数,示例,函数,实例,前面,下面,想要知道python什么时候加self就需要知道self的作用。下面我们centos如何安装python的ide?
centos如何安装python的ide?,环境,培训,方法,下面,以上,更多,内容,centos安装pythonIDE的方法:python常用的集成开发环境IDE1:Eclips+PyDevI如何在python代码中指定保存的文件
如何在python代码中指定保存的文件格式,代码,培训,文件格式,格式,二进制文件,文件,后缀,以上,方法,更多,python指定保存文件格式的方法:1、保python中的open函数如何编码?
python中的open函数如何编码?,数据,系统,可取,培训,文件,参数,函数,时候,表示,模式,python中的open函数可以通过在打开文件时添加encoding参Python写完代码怎么用
Python写完代码怎么用,代码,下来,数字,概念,培训,文本,模式,文件,程序,路径,python运行有两种方式,一种是在python交互式命令行下运行;另一种python为什么不适合web开发
python为什么不适合web开发,平台,培训,一致,环境,代码,技术,业务,性能,虚拟机,进程,python不适合web开发的原因:1、性能堪忧。写个httpserverpython和php学哪个做web开发好
python和php学哪个做web开发好,数据,较大,技术,培训,代码,市场,人工智能,行业,份额,网站,不少打算学编程的学生,想从事web开发行业,但是对于webPython如何实现excel筛选
Python如何实现excel筛选,数据,培训,表示,缺失,表格,示例,模块,手工,以上,标签,python实现筛选Excel数据可以使用pandas库来实现,具体的使用示Python中None如何判断
Python中None如何判断,培训,写法,字典,列表,语句,对象,都会,除此之外,逻辑,前提,python中None如何判断的方法:第一种:ifXisNone第二种:ifnotX当Xpython如何汇总多个exce
python如何汇总多个exce,数据,代码,培训,文件,数组,模块,命令,下面,以上,两个,python合并Excel文件需要使用xlrd、XlsxWriter两个模块。可以def在python中是什么?
def在python中是什么?,名称,代码,培训,函数,圆括号,参数,表达式,选择性,字符串,自变量,def在python中的意义:自定义一个函数你可以定义一个由