Article Directory
1: Single-line text overflows the container to be displayed
1. Single line of text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>苹果iPhone12国行版售价曝光:全系5G 最低5499元</p>
</body>
<style>
* {
margin: 0;
padding: 0;
}
p{
border: 1px solid black;
width: 300px;
height: 30px;
line-height: 20px;
/* 处理 */
/* 单行显示 */
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</html>
2. Multi-line text
height represents the vertical height, line-height represents the height of the text line, that is, the distance from the top to the bottom of the text. The
height is twice the line-height and only two lines can be displayed. The height is three times the line-height and three lines are displayed.
Truncate multiple lines
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p>苹果iPhone12国行版售价曝光:全系5G 最低5499元
苹果iPhone12国行版售价曝光:全系5G 最低5499元
</p>
</body>
<style>
* {
margin: 0;
padding: 0;
}
p{
border: 1px solid black;
width: 300px;
height: 40px;
line-height: 20px;
overflow: hidden;
}
</style>
</html>