我在我的网站上使用SlimScroll插件。
我想在窗口大小改变时重置/重新启动slimscroll函数,因为高度和宽度应根据#content_wrapper
div的高度和宽度而更改。
我尝试了几种方法,但似乎没有什么效果。下面是我的当前代码。有谁知道我如何实现这一点吗?
$('#content_wrapper').slimScroll({
width: $('#content_wrapper').css({'width':(($(window).width())-240)+'px'}),
height: $('#content_wrapper').css({'height':(($(window).height())-65)+'px'})
});
// scrollbar onresize resetten
$(window).resize(function(){
$('#content_wrapper').slimScroll({
width: $('#content_wrapper').css({'width':(($(window).width())-240)+'px'}),
height: $('#content_wrapper').css({'height':(($(window).height())-65)+'px'})
});
});
$(window)>height()
周围有括号 - 你不需要那个)。 - Puragheight: $('#content_wrapper').css({'height':(($(window).height())-65)+'px'})
。实际上,$()..表达式的返回值是一个jQuery对象而不是一个大小(宽度也是如此)。顺便说一下,其他的看起来都很好。 - Gergely Fehérvári