I have a <span> element including a long text. The span has a font-size set on its css stype. The text will be overflowed or wrapped if it is too long. I wonder whether there is a css style to make the text fit into the width of the span without wrapping. I want the css style to disable the font-size on the span and automatically apply a new font-size to fix the content.
Asked
Active
Viewed 992 times
0
Joey Yi Zhao
- 37,514
- 71
- 268
- 523
-
Is it okay to implement it using a custom function with jQuery/Javascript? – Masoud Keshavarz Apr 15 '18 at 06:47
-
It is ok if there is no automatical way – Joey Yi Zhao Apr 15 '18 at 06:47
1 Answers
0
Not sure if that's the case, but if your <span>'s width is dependent on the width or height of the viewport, you can use vw or vh CSS units.
MDN Docs
Mendy
- 7,612
- 5
- 28
- 42
-
I want to adjust the font size of the span automatically in case the text is too long – Joey Yi Zhao Apr 15 '18 at 04:52