显示有误

博客园 首页 新随笔 联系 订阅 管理

适用于内核为webkit的浏览器:
  display: -webkit-box;   -webkit-box-orient: vertical;   -webkit-line-clamp: 3;   overflow: hidden;




兼容大多数浏览器,但是最后一行无论文本是否溢出都会出现省略号,需配合js实现
  
p{position: relative; line-height: 20px; max-height: 40px;overflow: hidden;}
p::after{content: "..."; position: absolute; bottom: 0; right: 0; padding-left: 40px;
background: -webkit-linear-gradient(left, transparent, #fff 55%);
background: -o-linear-gradient(right, transparent, #fff 55%);
background: -moz-linear-gradient(right, transparent, #fff 55%);
background: linear-gradient(to right, transparent, #fff 55%);
}
 
posted on 2016-09-19 15:51  显示有误  阅读(203)  评论(0编辑  收藏  举报