kazzkiq / balloon.css

Simple tooltips made of pure CSS
https://kazzkiq.github.io/balloon.css/
MIT License
5.03k stars 448 forks source link

Tooltip causing extra overflow when inside an overflow container on mobile #149

Open mtsweir opened 3 years ago

mtsweir commented 3 years ago

We have tooltips on ratings within a table, the table is contained inside a div that lets the user scroll the table left to right on small screens, the container does this using:

.scrollable-container {
    display: block;
    overflow-x: auto;
}

We use this container on tables as our table data could consist of multiple columns, so we need this to scroll on small screens. The issue we are facing is that the tooltip extra creates white space on mobile resulting in extra scrolling - see example:

Screen Shot 2020-09-29 at 10 33 46 AM

This is the fixed width we set on our tooltips as the content displayed is a longish sentence, regardless of that without the width set its still an issue. Just reaching out to see if there's a possible solution here.

kazzkiq commented 3 years ago

This probably happens because the tooltip doesn't uses display: none, but opacity: 0 instead. The reason for that is that display doesn't animates, so if we used that property we would have no smooth in/out transitions.

In your case, if you're ok with no transitions in your tooltips, you could add this code in your project as a workaround:

[aria-label][data-balloon]::before,
[aria-label][data-balloon]::after {
  display: none;
}

[aria-label][data-balloon]:hover::before,
[aria-label][data-balloon]:hover::after {
  display: block;
}

This way the tooltips will only generate extra overflow when you hover the elements containing them.