一、文本溢出属性
文本溢出属性: 当一个盒子中的内容较多的时候,超出当前容器,就会用到文本溢出属性overflow
属性值:
1、visible 默认值,超出正常显示
2、hidden 超出隐藏
3、scroll 无论是否超出,都显示滚动
4、auto 超出显示滚动条 不超出不显示滚动条
下面演示 overflow: auto 的效果:
<!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 {
width: 200px;
height: 300px;
border: 1px solid #000;
margin: 10px auto;
overflow: auto;
}
</style>
</head>
<body>
<div>
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
文本溢出属性文本溢出属性文本溢出属性文本溢出属性
</div>
</body>
</html>
二、显示省略号
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;