Is it possible to fix the width
(or min-width
) of an element equal to when that element is filled with specific content?
Example: a button for selecting the month can have text of January, February, etc. I would like the button to always be the width as if the text is September (the longest string, visually). What happens currently, is the button is very small if the current selection is May or July, then much larger when the selection is November or September, and further, this can change the layout of other elements.
Of course I could set width
or min-width
using pixels, or a percentage, or vw
, etc -- but given the breadth of devices, screens, user control over zoom or font sizes, the only safe way is to guess at a size that is likely far larger than actually necessary, which itself looks bad and is undesirable.