html提供了一个功能:点击一个a标签,只要在href属性中写上#id就可以定位到那个id的位置,但是为了更好的用户体验,考虑使用缓动公式来达到这个需求。

缓动公式网上搜搜就有好多,五花八门的。自己写了一个相对比较好理解的,比较笨的方法用在很多个小例子上面。下面po下我的代码

html:

 1 <div class="theContent">
 2     
 3         <div class="nav">
 4             <ul>
 5                 <li id="nav1" class="title">导航一</li>
 6                 <li id="nav2" class="title">导航二</li>
 7                 <li id="nav3" class="title">导航三</li>
 8                 <li id="nav4" class="title">导航四</li>
 9             </ul>
10         </div>
11         <div class="content" id="txt1">内容一</div>
12         <div class="content" id="txt2">内容二</div>
13         <div class="content" id="txt3">内容三</div>
14         <div class="content" id="txt4">内容四</div>
15     
16     </div>
html代码

相关文章:

  • 2021-11-04
  • 2021-12-25
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-02-06
猜你喜欢
  • 2021-06-16
  • 2022-01-15
  • 2021-04-08
  • 2021-12-24
相关资源
相似解决方案