How do I determine the width of an auto sized element (no specified width
)?
In example I need to determine the width of a span
element.
The following do not work:
getElementsByTagName('span')[0].clientWidth;
getElementsByTagName('span')[0].getBoundingClientRect().width;
getElementsByTagName('span')[0].offsetWidth;
When looking at the Chrome developer console / computed tab the graph shows "auto x auto".
Chrome version 49.0.2623.87 m bug?
No frameworks.
Turns out that in Chrome if a parent element is set to display: none
all the properties will return as 0
which is incredibly lame.