Method 1: Use CSS overflow omission to solve The solution is as follows: CSS code: display: -webkit-box; display: -moz-box; white-space: pre-wrap; word-wrap: break-word; overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; -webkit-line-clamp:2; /*Display number of lines*/ Method 2: Use jQuery to intercept and replace text content The solution is as follows: js code: $(".text").each(function() { if ($(this).text().length > 20) {//Requires the number of words to be greater than 20 before replacing the number of words$(this).html($(this).text().replace(/\s+/g, "").substr(0, 80) + "...") //Start replacing from 0 to 80, and replace the remaining text content with "..." } }) The above two methods can be applied to the class name of the text content. Summarize The above are two common solutions to the problem of ellipsis characters displayed when HTML text overflows. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
<<: MySQL database JDBC programming (Java connects to MySQL)
>>: What is JavaScript anti-shake and throttling
In MySQL, databases correspond to directories wit...
MySQL UTF-8 encoding MySQL has supported UTF-8 si...
1. How to install? 1. [Run] -> [cmd] to open t...
Many people have encountered this error when star...
<br />This is a series of tutorials provided...
The Docker container that has been running shows ...
This article is part of a special series on the 2...
Swap space is a common aspect of computing today,...
The JD carousel was implemented using pure HTML a...
Table of contents Purpose Module Installation Bas...
1. Use Docker Compose to configure startup If you...
Table of contents 1. Install vmware 1.1 Download ...
The javascript function for converting <table&g...
SVG (Scalable Vector Graphics) is an image format...
Preface I encountered a situation at work: In the...