jquery - 窗口大小调整时的重置功能

标签 jquery restart

我正在为我的网站使用 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'})
    });
});

最佳答案

今天刚遇到这个问题,这对我有用: 初始化 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);
    });
  });

关于jquery - 窗口大小调整时的重置功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8214545/

相关文章:

linux - 如何在 docker 容器内自动启动服务

python - 按功能重新加载python flask服务器

android - Activity 崩溃后如何自动重启?

javascript - 如何在javascript中比较等于 '='

javascript - 所有浏览器中的 Highcharts 渲染问题

jquery.validate v. 1.9 忽略一些隐藏的输入

PowerShell 如何自动重启服务?

javascript - 使用具有固定页眉和页脚的 css 的可变内容 div 高度

jquery - 多个不同的水平导航菜单底部边框颜色?

mysql - 重启mySQL Server后表为空