Text overflow truncation and ellipsis are common business scenarios, mainly divided into single-line text overflow truncation and multi-line text overflow truncation. The truncation solution for single-line text is relatively simple, while multi-line truncation is relatively complex.
Single-line text overflow truncation can be achieved directly using CSS
, which has no compatibility issues. The ellipsis is only displayed when the text overflows, otherwise it is not displayed. The position of the ellipsis is just right. However, this solution can only be used for single-line text overflow truncation.
<section>
<div class="t1">Very long text that is very long</div>
<div class="t1">Not very long text</div>
</section>
<style type="text/css">
.t1{
white-space: nowrap; /* Prevent text from wrapping to the next line */
overflow: hidden; /* Truncate the text if it exceeds the specified width */
text-overflow: ellipsis; /* Display ellipsis when the text overflows */
}
</style>
Multi-line text overflow truncation can be achieved using CSS
with line-based calculation. The ellipsis is only displayed when the text overflows, otherwise it is not displayed. The position of the ellipsis is just right. However, the compatibility is average. The line-clamp
property is only supported by browsers with the WebKit
engine, and it is more suitable for mobile pages because mobile browsers are mostly based on the WebKit
engine.
<section>
<div class="t2">Not very long text</div>
<div class="t2">Very long text that is very long</div>
</section>
<style type="text/css">
.t2{
-webkit-line-clamp: 3; /* Limit the number of lines of text displayed in a block element Compatibility: https://caniuse.com/#search=line-clamp */
display: -webkit-box; /* Display as a flex container */
box-orient: vertical; /* Set the arrangement of the flex container's child elements */
overflow: hidden; /* Truncate the text if it exceeds the specified width */
text-overflow: ellipsis; /* Display ellipsis when the text overflows */
}
</style>
Multi-line text overflow truncation can be achieved using JS
with line-based calculation. It has no compatibility issues. The ellipsis is only displayed when the text overflows, otherwise it is not displayed. However, it requires JS
implementation, which goes against the principle of separating display and behavior. When the text contains a mix of Chinese and English, the position of the ellipsis may be slightly off.
<section>
<div class="t3">Short text</div>
<div class="t3">Very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very good. I have a 2001 4.0L XJ with 4.10 gears and 33" tires. I get 15-16mpg in the city and 20-21mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15-16mpg in the city and 18-19mpg on the highway. I have a 4.0L with 3.73 gears and 33" tires. I get 15
```html
<section>
<div class="t4">
<div class="text">Not a very long text</div>
</div>
<div class="t4">
<div class="text">A very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very good. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to put it. I think that's a good way to
```html
<!DOCTYPE html>
<html>
<head>
<title>Text Overflow Truncation Ellipsis</title>
<style type="text/css">
#container{
width: 300px;
border: 1px solid #eee;
position: relative;
}
section{
padding: 5px 0;
margin: 5px;
border-bottom: 1px solid #eee;
}
.t1{
white-space: nowrap; /* Prevent text from wrapping to the next line */
overflow: hidden; /* Truncate text if it exceeds the specified width */
text-overflow: ellipsis; /* Display an ellipsis (...) when text overflows */
}
.t2{
-webkit-line-clamp: 3; /* Limit the number of lines of text displayed in a block element */
display: -webkit-box; /* Display as a flex container */
-webkit-box-orient: vertical; /* Set the arrangement of flex items */
overflow: hidden; /* Truncate text if it exceeds the specified width */
text-overflow: ellipsis; /* Display an ellipsis (...) when text overflows */
}
.t4 {
max-height: 40px;
line-height: 20px;
overflow: hidden;
}
.t4::before{
float: left;
content:"";
width: 20px;
height: 40px;
}
.t4 .text {
float: right;
width: 100%;
margin-left: -20px;
word-break: break-all;
}
.t4::after{
float:right;
background-color: #fff;
content:'...';
width: 20px;
height: 20px;
position: relative;
left:100%;
transform: translate(-100%,-100%);
}
</style>
</head>
<body>
<div id="container">
<section>
<div class="t1">Not very long text</div>
<div class="t1">Very long very long very long very long very long very long very long very long text</div>
</section>
<section>
<div class="t2">Not a very long text</div>
<div class="t2">A very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text</div>
</section>
<section>
<div class="t3">Not a very long text</div>
<div class="t3">A very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text</div>
</section>
<section>
<div class="t4">
<div class="text">Not a very long text</div>
</div>
<div class="t4">
<div class="text">A very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text</div>
</section>
</div>
</body>
<script type="text/javascript">
(function(){
var lineNum = 3;
var elements = document.getElementsByClassName("t3");
Array.prototype.forEach.call(elements, element => {
var text = element.innerText;
var textLen = text.length;
var baseWidth = window.getComputedStyle(element).width;
var fontSize = window.getComputedStyle(element).fontSize;
var lineWidth = baseWidth.slice(0, -2);
var charCount = Math.floor(lineWidth / fontSize.slice(0, -2)); // Calculate the number of characters that can fit in one line
var content = "";
var totalStrNum = Math.floor(charCount * lineNum); // Total number of characters that can fit in multiple lines
var lastIndex = totalStrNum - textLen;
if (textLen > totalStrNum) content = text.slice(0, lastIndex - 3).concat('...');
else content = text;
element.innerText = content;
})
})();
</script>
</html>