-
shaunkillian
Hi
I want to create a tooltip for a specific class (.tooltip) of a GB Pro button using custom attributes and a little CSS, but I cannot get it to work.
Below is what I have tried.CSS
.tooltip {
position:relative; /* making the .tooltip span a container for the tooltip text */
border-bottom:1px dashed #000; /* little indicater to indicate it’s hoverable */
}.tooltip:before {
content: attr(data-text); /* here’s the magic */
position:absolute;/* vertically center */
top:50%;
transform:translateY(-50%);/* move to right */
left:100%;
margin-left:15px; /* and add a small left margin *//* basic styles */
width:200px;
padding:10px;
border-radius:10px;
background:#000;
color: #fff;
text-align:center;display:none; /* hide by default */
} -
Hi there,
the main issue is the:
content: attr(data-tooltip);had the wrong attribute name.
And there was some odd “spaces” in the CSS>Try this to get started:
.tooltip { position: relative; } .tooltip:after { content: attr(data-tooltip); position: absolute; top: 100%; left: 0; width: 100%; padding: 10px; background-color: #000; display: none; } .tooltip:hover:after { display: block; } -
shaunkillian
Thanks David
That was a huge help! I have been able to get it to work on the buttons within the page content. However, I modified the code for the button in the top bar, so that the tooltip appears on the left. Sadly, it doesn’t work.Button Settings: Below
CSS:
/*You Deserve It Button Animation in Topbar*/
.topbartooltip {
position: relative;
}
.topbartooltip:after {
content: attr(data-toptooltip);
position: absolute;
top: 0;
right: 105%;
width: 100%;
border-radius: 10px;
padding: 10px;
margin-right: 10px;
background-color: rgba(158, 62, 31, 0.5);
display: none;
justify-content: center;
text-align: center;
}
.tooltip:hover:after {
display: block;
} -
Fernando
Hi Shaun,
You’re missing a hover CSS rule for the top bar tool tip.
Your overall code should be something like this:
.tooltip, .topbartooltip { position: relative; } .tooltip:after { content: attr(data-tooltip); position: absolute; top: 100%; left: 0; width: 100%; padding: 10px; background-color: #000; display: none; } .topbartooltip:after { content: attr(data-toptooltip); position: absolute; top: 0; right: 105%; width: 100%; border-radius: 10px; padding: 10px; margin-right: 10px; background-color: rgba(158, 62, 31, 0.5); display: none; justify-content: center; text-align: center; } .tooltip:hover:after, .topbartooltip:hover:after { display: block; }
- You must be logged in to reply to this topic.