侧边菜单贴了

时间:2016-11-23 06:45:09

标签: javascript

没有从div的顶部粘贴左侧菜单。

<div class="col-md-3" id="leftCol">
  <ul class="nav nav-stacked" id="sidebar">
    <li><a href="#sec0">Section 0</a></li>
    <li><a href="#sec1">Section 1</a></li>
    <li><a href="#sec2">Section 2</a></li>
    <li><a href="#sec3">Section 3</a></li>
    <li><a href="#sec4">Section 4</a></li>
  </ul>
</div>

JS代码:

$('#sidebar').affix({
  offset: { top: 245 }
});

var $body   = $(document.body);
var navHeight = $('.navbar').outerHeight(true) + 10;

$body.scrollspy({
  target: '#leftCol',
  offset: navHeight
});

enter image description here

0 个答案:

没有答案