单行文本溢出显示省略号
必须满足三个条件
/* 1、先强制一行内显示文本 */
white-space: nowrap;
/* 2、超出的部分隐藏 */
overflow: hidden;
/* 3、文字用省略号替代超出的部分 */
text-overflow: ellipsis;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 150px;
height: 80px;
background-color: pink;
margin: 100px auto;
/* 1、先强制一行内显示文本 不允许换行*/
white-space: nowrap;
/* 2、超出的部分隐藏 */
overflow: hidden;
/* 3、文字用省略号替代超出的部分 */
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div>
东汉末年东汉末
年东汉末年
东汉末年东汉末年
东汉末年东汉末
年东汉末年
东汉末年东汉末年
东汉末年东汉末
年东汉末年
东汉末年东汉末年
东汉末年东汉末
年东汉末年
东汉末年东汉末年
</div>
</body>
</html>