CSS文字溢出处理问题

大兔子大兔子 提交于 2020-12-17 15:48:44

单行省略

div {
	white-space:nowrap; //断行处理:无断行
	text-overflow:ellipsis; //文字溢出处理:省略号
	overflow:hidden;	//溢出处理:隐藏
}

多行省略

  • 非IE和火狐
div {
	display:-webkit-box;
	-webkit-line-clamp:2;
	-webkit-box-orient:vertival;
	overflow:hidden;
}

-IE和火狐

.fade {
  position: relative;
  height: 3.6em; /* exactly three lines */
}
.fade:after {
  content: "";
  text-align: right;
  position: absolute;
  bottom: 0;
  right: 0;
  width: 70%;
  height: 1.2em;
  background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 1) 50%);
}

参考链接:https://css-tricks.com/line-clampin/

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!