CSS 2 Text Cover Ellipsis

I am trying to add a fixed div size that will wrap text, and also display ellipses when overflowing.

Is it possible?

This is where I am now:

.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>
Run codeHide result
+5
source share
1 answer

As far as I can tell, this is impossible, no: all text overflow support: white space is required for an ellipse: nowrap (which obviously limits it to one line and does not fulfill your first requirement),

For a multi-line wrapper, then an ellipsis, I think you are stuck with a javascript solution (like jTruncate ).

+3
source

All Articles