This article mainly shares with you how to limit the number of characters in CSS, mainly in the form of code. I hope it can help everyone.
html part
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <p id="nr"> 我是显示的内容 我是显示的内容 我是显示的内容 </p> </body> </html>
css part
width:20px; overflow: hidden; text-overflow: ellipsis; //限制字数显示 white-space: nowrap; //后面出来省略号
Related recommendations:
css limits the number of displayed words, and the excess text length is represented by ellipses
How to implement CSS limit number of words
html5 tag uses css to limit the number of displayed lines (number of words)
The above is the detailed content of How to limit the number of characters in css. For more information, please follow other related articles on the PHP Chinese website!