【问题标题】:How can I get the width of a layoutUnit that doesn't include its scrollbar?如何获得不包括其滚动条的 layoutUnit 的宽度?
【发布时间】:2011-01-18 15:50:53
【问题描述】:

我试图让我的布局更新另一个元素的宽度,但我需要获取它的宽度,不包括它的滚动条(如果确实存在)。在这种情况下,getMainContentBounds() 似乎会返回整个宽度以及滚动条。

我也尝试过 getSizes() 得到相同的结果。

myDataTable.on('postRenderEvent', function() {
    var bounds = YAHOO.specify.app.layout.getMainContentBounds();
    Dom.setStyle(YAHOO.util.Selector.query('div.yui-dt-hd', c.body), 'width', bounds.width+'px');
    Dom.setStyle(YAHOO.util.Selector.query('div.yui-dt-bd', c.body), 'width', bounds.width+'px');
});

【问题讨论】:

    标签: javascript layout yui


    【解决方案1】:

    为什么不将标记“元素”放在可滚动内容中。

    <div style="width: 200px; overflow: auto;">
        <div id="the-div-width">
            Your content.
        </div>
    </div>
    

    然后只专注于获取-div-width的实际宽度上的宽度...

    【讨论】:

    • 你说得对,我应该一直这样!
    猜你喜欢
    • 2015-05-25
    • 1970-01-01
    • 2013-11-04
    • 2023-02-20
    • 1970-01-01
    • 2014-08-27
    • 2013-11-12
    • 2011-03-13
    • 1970-01-01
    相关资源
    最近更新 更多