2010-02-19 56 views
0

我想讓我的佈局更新另一個元素的寬度,但我需要在其寬度不包括其滾動條(如果一個確實存在)。在這種情況下getMainContentBounds()似乎與滾動條一起返回整個寬度。如何獲取不包含滾動條的layoutUnit的寬度?

我也嘗試過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'); 
}); 

回答

1

爲什麼不把你的標記「元素」放在滾動條內?

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

然後,只需專注於獲得關於-DIV寬度的實際寬度寬...

+0

你說得對,我本來應該一直做這種方式! – 2010-02-19 17:22:04

相關問題