简体   繁体   English

添加粘性边栏

[英]Add sticky sidebar

I'm trying to use sticky sidebar with theiaStickySidebar from Github projects. 我正在尝试将粘性侧边栏与Github项目中的theiaStickySidebar一起使用。 As it described in above link, this should be an easy work. 如上面链接中所述,这应该很容易。 I use below HTML construction: 我使用以下HTML构造:

<aside class="sidebar">
 <div class="theiaStickySidebar">
 ...
 </div>
</aside>

This all these scripts need to work. 所有这些脚本都需要工作。

And also using scripts mentioned at Github page as below: 并且还使用Github页面上提到的scripts ,如下所示:

<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="dist/ResizeSensor.min.js"></script>
<script type="text/javascript" src="dist/theia-sticky-sidebar.min.js"></script>

<script type="text/javascript">
  jQuery(document).ready(function() {
    jQuery('.content, .sidebar').theiaStickySidebar({
      // Settings
      additionalMarginTop: 30
    });
  });
</script>

But this doesn't work currectly. 但这并不能立即生效。

Have I done something wrong in this process? 我在这个过程中做错了什么吗?

Jquery selector seems wrong. jQuery选择器似乎错误。 Use .ssidebar or theiaStickySidebar depending on which one you want as the sidebar. 使用.ssidebartheiaStickySidebar取决于要用作边栏的哪一个。

eg. 例如。

<script type="text/javascript">
  jQuery(document).ready(function() {
     jQuery('.content, .ssidebar').theiaStickySidebar({
      // Settings
      additionalMarginTop: 30
    });
  });
</script>

I just didn't delete extra class .content . 我只是没有删除额外的class .content For: 对于:

<aside class="sidebar">
 <div class="theiaStickySidebar">
 ...
 </div>
</aside>

Must use: 必须使用:

<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="dist/ResizeSensor.min.js"></script>
<script type="text/javascript" src="dist/theia-sticky-sidebar.min.js"></script>

<script type="text/javascript">
  jQuery(document).ready(function() {
    jQuery('.sidebar').theiaStickySidebar({
      // Settings
      additionalMarginTop: 30
    });
  });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM