简体   繁体   English

如何获得不包含滚动条的layoutUnit的宽度?

[英]How can I get the width of a layoutUnit that doesn't include its scrollbar?

I'm trying to make my layout update the width of another element, but I need to get at its width NOT including its scrollbar (if one is indeed present). 我试图使布局更新另一元素的宽度,但是我需要获得其宽度而不包括其滚动条(如果确实存在)。 getMainContentBounds() in this case seems to be returning the entire width along with the scrollbar. 在这种情况下,getMainContentBounds()似乎将返回整个宽度以及滚动条。

I have also tried getSizes() with the same result. 我也尝试过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');
});

Why don't you place your a marker "element" inside the scrollable. 您为什么不将标记“元素”放在可滚动内容中?

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

Then just focus on getting the width on the-div-width's actual width... 然后只专注于获取div-width的实际宽度上的宽度...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM