gpt4 book ai didi

css - offsetWidth vs scrollWidth : should be different, 但相同

转载 作者:行者123 更新时间:2023-11-28 04:25:10 25 4
gpt4 key购买 nike

我看过: Understanding offsetWidth, clientWidth, scrollWidth and -Height, respectively

但事实并非如此。例如,

.main {
width: 400px;
overflow: visible;
}

.main table {
width: 600px;
}

<div class="main">

<table>
<thead><tr><th>Foo</th><th>Bar</th></tr></thead>
<tbody>
<tr><td>Row1</td><td>Hello</td></tr>
<tr><td>Row2</td><td>World</td></tr>
</tbody>

</table>

</div>


---------------------------------------
|main |
| ----------------------------------------------------
| | table |
| ----------------------------------------------------
| |
| |
---------------------------------------

主div元素的offsetWidth和scrollWidth是一样的:400,应该分别是400和600吧?

最佳答案

似乎在为我工作?

http://codepen.io/anon/pen/EZEzGB

alert("Scrollwidth: " + document.getElementById('main').scrollWidth + "OffsetWidth: " + document.getElementById('main').offsetWidth);

您正在使用什么返回错误值?

关于css - offsetWidth vs scrollWidth : should be different, 但相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42008061/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com