如何获取不包含滚动条的布局单元的宽度?

发布于 2024-08-21 23:29:25 字数 468 浏览 2 评论 0原文

我试图让我的布局更新另一个元素的宽度,但我需要获取其宽度,不包括其滚动条(如果确实存在)。在这种情况下, 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');
});

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.

I have also tried getSizes() with the same result.

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');
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烂人 2024-08-28 23:29:25

为什么不在可滚动内容中放置标记“元素”呢?

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

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

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文