my question is different but similar to Sliding icon next to dynamic text with ellipsis
Showing an icon after truncated text with ellipsis. want to show icon ONLY if text is truncated and ellipsis shown.
Here is sample I tried. https://jsfiddle.net/poonkave/6sfbhu9w/
issue is icon is still displayed even if text is short.
any CSS solution?
<div class="block-wrap">
<div class="block">
<div class="icon">
</div>
<div class="desc">
This is a very very very
very very very very very very very
very very very very very very
very very very very very very
very very very very very very
very very long description
</div>
</div>
.block-wrap {
display: inline-block;
max-width: 100%;
}
.block {
width: 100%;
}
.desc {
display: block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.icon {
float: right;
margin-left: 10px;
width: 20px;
height: 14px;
background-color: #333;
}