我在我的网站上使用SlimScroll插件.
我想在窗口调整大小时重置/重新启动slimscroll函数,因为高度和宽度应根据#content_wrapperdiv 的高度和宽度进行更改.
我通过几种方式尝试过,但似乎没有什么可以做到的.在我当前的代码下面.有谁知道我怎么能做到这一点?
$('#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'})
});
});
Run Code Online (Sandbox Code Playgroud)
小智 7
今天刚遇到这个问题,这对我有用:初始化slimScroll时,它会添加一个带有类"slimScrollDiv"的div.您可以更改此div的高度并将其设置为与包装div相同...
$(document).ready(function(){
$('#scrollDiv').slimScroll({
height: 'auto'
});
$(window).resize(function(){
var h=$(window).height()-250;
$('#scrollDiv').height(h);
$('.slimScrollDiv').height(h);
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8246 次 |
| 最近记录: |