html编程怎么让过长的文字只显示1行

html编程怎么让过长的文字只显示1行,第1张

<div style="width:150px height:30px line-height:30px overflow:hidden position:relative">这里输入文字内容。这里输入文字内容。</div>

设置高宽和溢出隐藏就行了,

 /*一行表示**/

     overflow: hidden

white-space: nowrap

text-overflow: ellipsis

/***2行表示**/

display: -webkit-box

overflow: hidden

text-overflow: ellipsis

word-wrap: break-word

white-space: normal !important

-webkit-line-clamp: 2

-webkit-box-orient: vertical


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7025572.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-31
下一篇 2023-03-31

发表评论

登录后才能评论

评论列表(0条)

保存