简体   繁体   English

CSS 2 Line Text Wrap Ellipsis

[英]CSS 2 Line Text Wrap Ellipsis

I'm trying to add a fixed size div that would text wrap and also show ellipsis on overflow. 我正在尝试添加一个固定大小的div,它将文本换行并在溢出时显示省略号。

Is this possible? 这可能吗?

Here is where I'm at so far: 这是我到目前为止的地方:

 .mydiv { font-family: Georgia, "Times New Roman", Times, serif; font-size: 14px; line-height: 20px; display: block; overflow: hidden; text-overflow: ellipsis; width: 120px !important; height: 40px !important; border: 1px solid #000000; } 
 <div class="mydiv"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> 

As best as I can tell, this is not possible, no: all support for text-overflow: ellipsis requires white-space: nowrap (which obviously constrains it to a single line, and doesn't fulfill your first requirement). 据我所知,这是不可能的,不是:所有支持文本溢出:省略号需​​要white-space:nowrap(显然将其限制为单行,并且不符合您的第一个要求)。

For multiline wrapping, then ellipsis, I think you're going to be stuck with a javascript solution (for example jTruncate ). 对于多行包装,然后是省略号,我认为你将会遇到一个javascript解决方案(例如jTruncate )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM