I have SPAN
s (placed inside LI
) on which I want to activate the ellipsis (...)
if they are overflowing. However, the problem is I also want them to wrap around and use all the available height.
Consider Snippet #1: This is not what I want because Box #1 shouldn't be ellipsified on one line. There is plenty of Height available, so in this case it should wrap around. Box #2 looks OK here.
.spanbox {
width: 136.5px;
text-overflow: ellipsis;
white-space: nowrap; /* TOGGLING THIS */
overflow: hidden;
display: inline-block;
}
.item1 {
border: 1px solid black;
height: 134px;
width: 136.5px;
}
.item2 {
border: 1px solid black;
height: 17px;
width: 136.5px;
}
<li class="item1">
<span class="spanbox">
(50min) Food preparation and serving
</span>
</li>
<li class="item2">
<span class="spanbox">
(5min) Talking with friends
</span>
</li>
Here's Snippet #2: this isn't what I want either, because now there's no Ellipsis at all in Box #2. But now I got the multi-line wrapping in Box #1, so that looks OK. I turned off the white-space: nowrap
style.
.spanbox {
width: 136.5px;
text-overflow: ellipsis;
/*white-space: nowrap;*/ /* TURNED OFF NOW */
overflow: hidden;
display: inline-block;
}
.item1 {
border: 1px solid black;
height: 134px;
width: 136.5px;
}
.item2 {
border: 1px solid black;
height: 17px;
width: 136.5px;
}
<li class="item1">
<span class="spanbox">
(50min) Food preparation and serving
</span>
</li>
<li class="item2">
<span class="spanbox">
(5min) Talking with friends
</span>
</li>
The goal is to use all the available Height in Box #1, but activate the ellipsis on Box #2, so a combination of the above two snippets. Is this possible?