平滑滚动无效?

时间:2017-06-25 16:45:53

标签: javascript jquery html css

所以我只是按照youtube教程来完成smoothscroll的工作。视频中的人将这些设置在

的底部

<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.2/jquery.scrollTo.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-localScroll/1.4.0/jquery.localScroll.min.js"></script>
<script src="js/smoothscroll.js"></script>

.js文件包含:

$('.nav').localscroll();

在我的主要内容中,我的侧边栏链接是:

<div id="sidebar">
	<h4><a href="#Atoms" >Atoms, Elements and the Periodic Table</a></h4>
	<h4><a href="#Group-1">Group 1</a></h4>
	<h4><a href="#Group-7">Group 7</a></h4>
	<h4><a href="#Group-0">Group 0 - Noble Gases</a></h4>
</div>

所以我使用#sidebar作为.js文件夹中的目标。 (这是正确的吗?)

在我的.css文件中,id侧边栏是:

#sidebar {
  text-decoration: none;
  position: fixed;
  margin-left: 0;
  margin-right: 5%;
  width: 15%;
  background-color: #f9f9f9;
  overflow: auto;
  word-wrap: break-word;
  top: 60px; 
  bottom:0;
}

我相信我的语法是正确的(虽然我是新编码,但可能不是)。但是,平滑滚动不起作用,任何想法为什么?

干杯!

0 个答案:

没有答案