【问题标题】:Jquery custom scrollbar and IE issueJquery自定义滚动条和IE问题
【发布时间】:2016-04-21 13:10:36
【问题描述】:

我使用 jquery 自定义滚动条插件来显示自定义滚动条。 Link

它适用于所有浏览器和设备,但有一个奇怪的问题。虽然它在 IE 中也可以正常工作,但滚动条在不需要滚动时是可见的。我还使用了回调函数(onOverflowYNone)来删除它,但它会删除滚动功能。如果比率接近 1,我该如何移除滚动条。

【问题讨论】:

    标签: jquery mcustomscrollbar


    【解决方案1】:

    您可能会执行以下操作:

    /*CSS*/
    .hidden { display: none; }
    
    // jQuery
    $(document).ready(function() {
        $(window).resize(function() {
            var windowHeight = $(this).height();
            var containerHeight = $(".<container-class>").height(); //<container-class> is just a placeholder. Your real class should go here.
            if (containerHeight <= windowHeight) {
                $(".mCustomScrollbar").addClass("hidden"); // This is the example default class that was in the link you provided
            } else {
                $(".mCustomScrollbar").removeClass("hidden");            
            }
        });
    });
    

    这将等待文档加载,然后附加一个调整大小操作侦听器,该侦听器将在调整窗口大小的任何时候运行此检查以查看窗口和容器的尺寸。如果您愿意,您还可以将此检查外部化并将其添加到更多操作侦听器中。

    显然,您应该调整评估以满足您的需求,但核心概念保持不变。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 2013-07-02
      相关资源
      最近更新 更多