You can use display: inline-block
.
it works well on Edge and Chrome:
width: fit-content;
height: fit-content;
You can use:
width: -webkit-fit-content;
height: -webkit-fit-content;
width: -moz-fit-content;
height: -moz-fit-content;
EDIT: No. see http://red-team-design.com/horizontal-centering-using-css-fit-content-value/
you can also use
word-break: break-all;
when nothing seems working this works always ;)
Source: Stackoverflow.com