美文网首页
CSS 文本溢出隐藏显示省略号

CSS 文本溢出隐藏显示省略号

作者: consolelog | 来源:发表于2022-10-24 18:29 被阅读0次
    1. 单行文本溢出
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    
    1. 多行文本溢出
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1; /*最大行数*/
    

    该方法参考GitHub - tailwindlabs/tailwindcss-line-clamp, 可能存在兼容问题, 使用时请在多个浏览器测试以保证结果准确性

    Note that the line-clamp-{n} set other properties like display and overflow in addition to -webkit-line-clamp which are not unset by line-clamp-none, so depending on what you are trying to achieve you may need to explicitly override those properties with utilities like flex or overflow-visible as well.

    相关文章

      网友评论

          本文标题:CSS 文本溢出隐藏显示省略号

          本文链接:https://www.haomeiwen.com/subject/evmgzrtx.html