简体   繁体   中英

How do I get the exact, floating point width of an element?

I am trying to get the exact width of a table cell. In IE9's developer toolbar, the Layout tab shows that it has a width of 203.68px, but element.clientWidth and other methods all report the rounded integer value of 204px.

I am trying to create another element that will line up perfectly with this table cell, but since IE8/9 (and Firefox 4 and Chrome 12) display the table cell at its true, floating point width (or perhaps semi-rounded, like 203.5px or 203.75px), my other element is slightly wider.

Instead of trying to use the same exact width for the other element, you may want to consider changing your markup so these elements have some kind of direct relationship.

In case of td , it may be a td in a different column, or an inner element.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM