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> |
0 replies
|
I was thinking the same. Tried <br> and \n but no dice. Would be a good addition. |
0 replies
|
Not directly a solution but for me using data-placement="left" / data-placement="right" helped to keep the tooltip visible. |
0 replies
|
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;
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
\nand<br>without success.Here's my code sample:
All reactions