美文网首页
css 一行/多行 溢出

css 一行/多行 溢出

作者: 哼_ | 来源:发表于2022-01-05 16:47 被阅读0次

溢出文本一行展示
text-overflow: ellipsis;只对display:inline;起作用


.text{
     white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    word-break: break-all;
}

溢出文本多行展示

 .text {
     overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box; 
    -webkit-line-clamp: 2;   // 多行
    -webkit-box-orient: vertical;
}

文章参考来源

行内文本过多, 想要实现,

文本少, 居中显示, 文本多, 就靠左显示

需要在行内标签 外部加一个父元素
比如

<div style='text-align:center;'>
      <p style='display:inline-block;text-align:left;'>我是内容</p>
</div>

相关文章

网友评论

      本文标题:css 一行/多行 溢出

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