gpt4 book ai didi

javascript - 如何在 chrome 和 firefox 上设置表格高度

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

我有一个 HTML 表格标签如下

<table class="globaltable" border="0" cellspacing="0" cellpadding="0" width="100%" align="center" height="72%" onclick="alert(this.offsetHeight)">  

IE8 中,我的 onclick 值为 420,在 chrome 中为 480,在 firefox 中为 472。如何使它统一跨不同的浏览器。

最佳答案

style 属性中提及高度。如果您在 px 中使用高度,则它在所有浏览器中都很常见。如果您使用 %,它会因浏览器的可计算性而异。

<table class="globaltable" border="0" cellspacing="0" cellpadding="0"  width="100%"
style="height: 720px;" align="center" onclick="alert(this.offsetHeight)">
<tr>
<td>

</td>
</tr>

关于javascript - 如何在 chrome 和 firefox 上设置表格高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27599165/

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