JSFiddle - React, Tailwind, and code Playground
by Valentin Sarychev
HTML
<span class="text">
<span class="inner left">Click to add overflow</span>
<span class="inner right"> long text here</span>
</span>
<div class="bottom"></div>
CSS
.text {
line-height: 50px;
font-size: 20px;
background: wheat;
cursor: pointer;
display: inline-block;
-webkit-user-select: none;
}
.left {
font-size: 12px;
font-weight: bold;
}
.right {
display:inline-block;
text-overflow: ellipsis;
width: 100px;
white-space: nowrap;
}
.bottom {
background: red;
height: 100px;
}
.overflow {
overflow: hidden;
vertical-align: top;
}
JavaScript
$('.text').on('click', function() {
$(this).toggleClass('overflow');
$('.right').toggleClass('overflow');
})