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
Application scenario 1: Domain name-based redirec...
Communication between containers 1. Network shari...
1. Demand A picture moves from left to right in a...
I've been writing a WeChat applet recently an...
A simple example of how to use the three methods ...
Download the MySQL installation package. I downlo...
1. Create a database 2. Create a table 1. Create ...
export default ({ url, method = 'GET', da...
1. Introduction By enabling the slow query log, M...
Three knowledge points: 1. CSS descendant selecto...
Question: Is the origin server unable to find a r...
CSS scroll bar style modification code .scroll::-...
1. Multiple calls to single arrow Once a single a...
1. Add Maria source vi /etc/yum.repos.d/MariaDB.r...
Table of contents 1. Solution 1 (UDF) Demo Case 2...