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
How to center the entire page content and how to m...
This article shares the specific code for JavaScr...
This article example shares the specific implemen...
Table of contents Problem Description The general...
How to turn a jar package into a docker container...
Table of contents 1. beforeCreate & created 2...
This article shares the specific code for JavaScr...
SRIOV introduction, VF pass-through configuration...
1. I purchased a VPS and CentOS system, and found...
Table of contents Preface vue-cli 2.0 version vue...
The following is a picture mouse hover zoom effec...
Add in the <Head> tag <meta http-equiv=&q...
1. Windows Server 2019 Installation Install Windo...
Table of contents 1. Custom import in packaging t...
Preface Currently, the front-end solves cross-dom...