Is it possible to show a tooltip when the content can't fit inside the element? Using title attribute shows the tooltip regardless.
I've googled some examples, but there was nothing about tooltip showing conditions.
In this example I want to see the tooltip only when the text is too long:
.limiter
{
width: 100px;
}
.container
{
margin: 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
border: 1px solid #000000;
}
<div class="limiter">
<div>Hover cells:</div>
<div class="container" title="short text">short text</div>
<div class="container" title="short">short</div>
<div class="container" title="long text long text long text">long text long text long text</div>
</div>
It is possible to use JavaScript.
Limitations:
- I don't know in advance, what text a cell will contain (basically it's a template for angularjs)
- I don't know in advance, what number of letters can it display
- User can resize cells