大佬教程收集整理的这篇文章主要介绍了css – 如何进行文本溢出:两行省略?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
text-overflow: ellipsis; white-space: nowrap;
然后虚线显示正确但它在一行上被切断.当我这样做时:
text-overflow: ellipsis;
<div class="container"> <span>text...</span> </span>
添加此CSS:
.container { overflow: hidden; position: relative; BACkground: white; //or other color } .container:after { content: '...'; //the ellipsis position: absolute; //positioned in bottom-right bottom: 0; //... right: 0; //... padding: 0 0.3em; //give some separation from text BACkground: inherit; //same color as container } .container span:after { content: '\0000a0'; //a space position: absolute; //to cover up ellipsis if needed width: 1000px; //... z-index: 1; //... BACkground: white; //must match container's color. can't use inherit here. }
调整容器大小,您将看到省略号仅在必要时显示.
应该适用于所有现代浏览器.
以上是大佬教程为你收集整理的css – 如何进行文本溢出:两行省略?全部内容,希望文章能够帮你解决css – 如何进行文本溢出:两行省略?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。