如下 demo
, 纵向展示时,横向溢出省略的方案不适用,还有其他的 css 解决方案没?
overflow: hidden;
text-overflow: ellipsis;
如下 demo
, 纵向展示时,横向溢出省略的方案不适用,还有其他的 css 解决方案没?
overflow: hidden;
text-overflow: ellipsis;
用一个容器来裁剪内容,然后再用线性渐变新建一个白色透明的遮罩,这样看起来文字被截断然后显示省略号的效果
.container {
width: 20px; 自定义宽度 */
height: 100px; /* 自定义显示的高度 */
overflow: hidden;
position: relative;
}
.container::after {
content: "..."; /* 省略号 */
font-size: 12px; /* 调整省略号大小 */
position: absolute;
bottom: 0;
left: 0;
width: 100%;
background: linear-gradient(to top, white, transparent); /* 根据背景颜色来改 */
pointer-events: none;
}
3 回答5.2k 阅读✓ 已解决
5 回答2k 阅读
2 回答2k 阅读✓ 已解决
1 回答3k 阅读✓ 已解决
3 回答2.5k 阅读
2 回答1.1k 阅读✓ 已解决
2 回答2.2k 阅读
可以用垂直排版解决
https://codepen.io/xboxyan/pen/yLZaLQw