1
I am searching since yesterday how to display a text while resting the mouse pointer on an image and see information (as a title
, but where I can edit the font color, background and etc) and with the help of a friend that was the closest I got:
You can’t see the mouse pointer because it’s a print, but the mouse is on top of the red bag, the item on the upper right side of the screen, next to the red spades.
The problem is that instead of the text appearing at the foot of the mouse pointer (as in a title
) it always appears in that upper left corner. I wanted to leave like this:
Also, unlike the title
I want the message to appear instantly when resting the mouse, instead of appearing with delay. Here the link of a page where you can see a template working perfectly
[data-tooltip] {
position: relative;
font-weight: bold;
cursor: help;
}
[data-tooltip]:after {
display: none;
position: absolute;
top: -5px;
left: calc(100% + 2px);
padding: 5px;
z-index: 10;
font-size: 12px;
border-radius: 3px;
content: attr(data-tooltip);
white-space: nowrap;
background-color: #000;
color: Yellow;
}
[data-tooltip]:hover:after {
display: block;
}
<div>
<span data-tooltip="Unclear Backpack"><img src="https://picsum.photos/200" ></span>
</div>
css of the img class, which defines the position where each image will appear
#piv_flex .itm { background-image: url("/engine/img/bg.png"); }
#piv_flex .itm-1 { left: 48px; top: 39px; }
#piv_flex .itm-2 { left: 11px; top: 53px; }
#piv_flex .itm-3 { left: 85px; top: 53px; }
#piv_flex .itm-4 { left: 48px; top: 76px; }
#piv_flex .itm-5 { left: 85px; top: 90px; }
#piv_flex .itm-6 { left: 11px; top: 90px; }
#piv_flex .itm-7 { left: 48px; top: 113px; }
#piv_flex .itm-8 { left: 48px; top: 150px; }
#piv_flex .itm-9 { left: 11px; top: 127px; }
#piv_flex .itm-10 { left: 85px; top: 127px; }
I simplified the code because there is no need to insert PHP in your question. I removed the class from the tag
<img>
because you didn’t put her CSS. If important, edit the question by adding the class and the corresponding CSS again– Rafael Tavares
Dude no. After all it was not very clear what you want... the tooltip is already appearing in your code example... Do you want the tooltip to follow the mouse pointer? Or that the tooltip appears centered just below the image?
– hugocsl
Accessing the page that I Linked on the topic of seeing better if you are on a desktop/notebook, but basically I want the tooltip to be below the mouse pointer, exactly as it would be on a
title
, do not need to follow the mouse. Centered below the image would also solve– Lurk