1. 单行省略
.ellipsis {overflow: hidden;white-space: nowrap;text-overflow: ellipsis;
}
2. 双行省略(webkit 内核)
.ellipsis {display: -webkit-box; /* 显示多行文本容器 */-webkit-box-orient: vertical;-webkit-line-clamp: 2; /*显示行数*/overflow: hidden; /*隐藏多出部分文字*/text-overflow: ellipsis; /*用省略号代替多出部分文字*/
}
3. 通用省略
.ellipsis {position: relative;line-height: 1.4em;height: 2.8em; /* 这里的高度是line-height的两倍 */overflow: hidden;
}
.ellipsis::after {content: "...";position: absolute;bottom: 0;right: 0;padding: 0 5px 1px 30px;background: linear-gradient(to right, rgba(255, 255, 255, 0), #ffffff 50%) repeatscroll 0 0 rgba(0, 0, 0, 0);
}