-
Stefanie
Hi team,
I’m looking for a way to create tooltips (for links or general for elements).
Specifically, when I hover over a link that opens in a new tab, I need a tooltip to appear that says: “opens a new window”How can I implement this in GB?
I have seen something similar on your GP Pricing page
Is there a snippet for this?
Thank you!
-
Hi there,
You can create a
:before
selector for the link, and set it todisplay:none
in normal state, and set it todisplay: block
in hover state.You can position it by setting the
position
toabsolute
(the link/text main selector needs to be set toposition: relative
), and play with the left/right/bottom/top inset values. -
Stefanie
Sorry, I can’t manage that.
How can I set a :before selector to a hover state?
Where can I save the text that should appear in the tooltip on hover? -
How can I set a :before selector to a hover state?
Create a selector
.gb-element-xxxxxxx:hover:before
.Where can I save the text that should appear in the tooltip on hover?
In the
content
field of the.gb-element-xxxxxxx:before
selector. -
Stefanie
Hi Ying,
thanks for your hints, but unfortunately that doesn’t work at all.
Can you tell me how it was done on your pricing page?
link in private
-
ke.nikka
Please consider voting for tooltips: https://feedback.generatepress.com/113.
-
Alvind
Hi there,
The tooltip used on the GeneratePress site is powered by a third-party library called Microtip.
If you’d like to implement the same approach, you can follow the official documentation here:
https://microtip.vercel.app/ -
Stefanie
Hi Alvind,
thanks for the tip with the library! It works very well.
There is just one last question:
I would like to add a tooltip to individual links within a paragraph.Could you take a look at the page in the private field?
Do you have any idea how I can addHTML attributes
to the linked words in the text?Thank you!
-
I don’t think it’s possible to add attributes to the linked words, but you can target it with selector
.gb-text-xxxxxx a
.Below is a text block that made by the method I said, have a look 🙂
<!-- wp:generateblocks/text {"uniqueId":"781a4e5d","tagName":"p","styles":{"a":{"color":"#ed1515","position":"relative"},"a::before":{"content":"\u0022test\u0022","position":"absolute","display":"none","bottom":"100%","left":"50%","transform":"translate3d(-50%, 0px, 0px)"},"a:hover::before":{"display":"block"}},"css":".gb-text-781a4e5d a{color:#ed1515;position:relative}.gb-text-781a4e5d a::before{content:\u0022test\u0022;position:absolute;display:none;bottom:100%;left:50%;transform:translate3d(-50%,0px,0px)}.gb-text-781a4e5d a:hover::before{display:block}"} --> <p class="gb-text gb-text-781a4e5d">This is a paragraph. Within this paragraph <a href="https://gp-one.carenda.de/tooltip/#"><strong><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-base-2-color">one or more words</mark></strong></a> should be linked.</p> <!-- /wp:generateblocks/text -->
-
Stefanie
Hi Ying,
Unfortunately, that’s not what I mean.
At Alvind’s suggestion, I have integrated the Microtip Tooltip Library.
And it works well, as you can see on my page.
The blue button is equipped with a tooltip from the Microtip Library.This works very well for the button because it is a block element.
However, I need the tooltip for an inline element (in the middle of a paragraph).For the tooltip to work, the HTML must be equipped with certain attributes:
https://prnt.sc/FJwSMg3zJWwz
Usage: https://prnt.sc/KR3ZR2_xPvxuHow can I get GB to set a
<span>
tag within the paragraph so that I can assign theHTML attributes
to this span tag? -
How can I get GB to set a <span> tag within the paragraph so that I can assign the HTML attributes to this span tag?
You can use the WP highlight option in the floating toolbar, but it adds <mark> tag around the link, and the text block does not have the option for you to fill attributes for its child elements.
So no, I don’t think you can do so. You might need to use a custom HTML block to manuuly add the text/link and attributes.
-
Stefanie
Ok, thanks for your help, Ying!
You might need to use a custom HTML block
Yes, I’ve done it this way now if need be.
Thanks 🌷
-
You are welcome 🙂
- You must be logged in to reply to this topic.