我正在使用来自http://startbootstrap.com/templates/sb-admin-v2/的管理员模板,但我发现如果侧面菜单项超过页面高度而没有滚动,那么当菜单项或页面高度发生变化时,如何将滚动添加到静态侧面菜单? 比如http://responsiweb.com/themes/preview/ace/1.3/
您可以更改浏览器高度以查看问题。
答案 0 :(得分:1)
只需使用滚动插件like niceScroll并使用此代码:
var sideMenuCheck = function () {
var ss = $("#side-menu");
ss.css({
'height': ss.height() + 'px'
});
document.body.style.overflow = "hidden";
var viewportHeight = $(window).height();
document.body.style.overflow = "";
var menuParent = ss.parent();
menuParent.css({
'height': (viewportHeight - 50) + 'px',
'overflow': 'hidden'
});
menuParent.niceScroll();
};
$(document).ready(function () {
sideMenuCheck();
});
$(window).resize(function () {
sideMenuCheck();
});
注意:此答案是代表OP发布的。