Replies: 4 comments
-
I didn't find how to do it so I decided to switch to an article instead that I display/hide on hover. Here's the code if someone's interested. document.addEventListener('DOMContentLoaded', function () {
const hint = document.querySelector('a#tooltip-hint');
hint.addEventListener('mouseenter', toggleTooltip);
hint.addEventListener('mouseleave', toggleTooltip);
});
function toggleTooltip(event) {
const tooltip = document.querySelector('article#tooltip');
tooltip.style.display = (tooltip.style.display === 'block') ? 'none' : 'block';
} article#tooltip {
display: none;
font-size: 0.875em;
} <a id="tooltip-hint" href="#">?</a>
<article id="tooltip">
Lorem ipsum sin amet
</article> |
Beta Was this translation helpful? Give feedback.
-
I was thinking the same. Tried <br> and \n but no dice. Would be a good addition. |
Beta Was this translation helpful? Give feedback.
-
Not directly a solution but for me using data-placement="left" / data-placement="right" helped to keep the tooltip visible. |
Beta Was this translation helpful? Give feedback.
-
I'm using this to at least allow line breaks if the text is too long: [data-tooltip]::before {
max-width: max(100%, 15rem);
width: max-content;
white-space: initial;
text-indent: 0;
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How does one add a line break inside a tooltip? I've tried both
\n
and<br>
without success.Here's my code sample:
Beta Was this translation helpful? Give feedback.
All reactions