css文本超出省略

一、单行

<div class="div">这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文</div>
.div {
  background-color: green;
   100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

二、多行

  1、私有属性

<div class="div">这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文</div>
.div {
  background-color: green;
   100px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

  2、:before和:after

<div class="div">这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文这是一段中文</div>
.div {
  background-color: green;
   100px;
  height: 63px;
  position: relative;
  overflow: hidden;
  text-align: justify;
}

.div:before {
  content: "...";
  background-color: green;
   18px;
  height: 21px;
  position: absolute;
  right: 0;
  bottom: 0;
}

.div:after {
  content: "";
  background-color: green;
   18px;
  height: 63px;
  position: absolute;
  right: 0;
}
原文地址:https://www.cnblogs.com/linding/p/13278656.html