【问题标题】:How to get the dimensions of the scroll bars? [duplicate]如何获得滚动条的尺寸? [复制]
【发布时间】:2011-02-12 22:19:48
【问题描述】:

可能重复:
Javascript : Get the browser's scrollbar sizes

我有一个包含许多行和列的 HTML 表。因此,它具有垂直和水平滚动条。

如何在 Javascript/jQuerys 中获取这些滚动条的像素尺寸?

【问题讨论】:

    标签: javascript jquery html


    【解决方案1】:

    Ben Alman 有一个很好的 scrollbarWidth plugin,效果很好。

    var content = $('#content').css( 'width', 'auto' ),
      container = content.parent();
    
    if ( content.height() > container.height() ) {
      content.width( content.width() - $.scrollbarWidth() );
    }
    

    【讨论】:

      猜你喜欢
      • 2013-04-17
      • 1970-01-01
      • 2015-07-12
      • 2011-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多