xiaokeqi / i-learned

1 stars 0 forks source link

css多行截断 #24

Open xiaokeqi opened 5 years ago

xiaokeqi commented 5 years ago

单行: overflow: hidden; text-overflow:ellipsis; white-space: nowrap; 多行: display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; //行数 overflow: hidden; 多行截断且考虑兼容性 p{ position: relative; line-height: 20px; max-height: 40px; overflow: hidden; } p:after{ content:'...'; position: absolute; bottom:0px; right: 0px; //background:linear-gradient(to right, transparent, #fff 55%); background: #fff; padding-left: 5px; }