web兼容火狐浏览器默认显示2行,多出去的省略号代替 以及其他正常浏览器写法

web兼容火狐浏览器默认显示2行,多出去的省略号代替

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%);
}

默认显示一行 多省略号代替

text-overflow:ellipsis;
overflow:hidden;
white-space: nowrap;

默认显示2行 多余省略号代替

overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;

猜你喜欢

转载自blog.csdn.net/qq_43071910/article/details/83508662
今日推荐