如何获得真正的宽度TD表 [英] how to get real width td table
本文介绍了如何获得真正的宽度TD表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在html中创建了一个表格,这个表格
宽度是988 px, tr
宽度是100%表
宽度。
在表标记中存在5 td
标记这个 td
标签宽度为20%。
当我用jQuery获得这些标签时(
198
197
tag)显示在控制台中: 198
197
198
但是我在控制台 197.59
我想得到这个值不是这197或198
解决方案
$ b element.getBoundingClientRect()。width
显示浏览器呈现的确切宽度。
MDN参考: getBoundingClientRect
I create one table in html and this table
width is 988 px and tr
width is 100% table
width.
in table tag exist 5 td
tag that this td
tag width 20%.
when I get with these tags with jQuery (td
tag) show me in console this :
198
197
198
197
198
but I see this tags width in console 197.59
I want get this value not these 197 or 198
解决方案 More precise than element.offsetWidth
is:
element.getBoundingClientRect().width
it shows exact width as rendered by the browser.
MDN reference: getBoundingClientRect
这篇关于如何获得真正的宽度TD表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录
关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆