1.单行文本溢出
1.强制一行内显示文本 white-space: nowrap
2.溢出部分隐藏 overflow : hidden;
3.文字溢出用省略号显示 text-overflow : ellipsis
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div{
background-color: blanchedalmond;
width: 100px;
height: 100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div>
市场部那些绝非和他发我看看初步报价打开
</div>
</body>
</html>
2.多行文本溢出
- overflow : hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
这个属性比较合适WebKit浏览器或移动端(绝大部分是WebKit内核的)浏览