Jump to content

tooltip


Q695

Recommended Posts

Whilst that's called a tooltip, it's probably built using divs and some js to hide/show the div on mouse hover on the button.. Would be fairly simple.

Just create a div and style it up how you want it to look (including any images you might want in there). Position it on the page where you want it, and then set it to hidden or display none.

Then use some javascript to show that div when someone hovers over the button/link/whatever you want the tooltip to be attached to.

 

Hopefully that'll get you started.

 

Denno

Link to comment
Share on other sites

After I replied I actually noticed that if you scroll down on that page, they show you some html with exactly how they make it, so you should be able to follow that.

 

The main css property's you're going to use are 'display' or 'visibility'. Do some googling to find out how they work.

Essentially you will create a css class, called hidden (or whatever you want), and apply that to the div by default. Then, when the user hovers over the button, use JavaScript to remove that class. As soon as they mouse off the button, your JavaScript should detect that, and apply your css class back to the div.

 

Alternatively, you could do it using just JavaScript. Give your div an id of tooltip. In your JavaScript, hide that div on page load, and then show it again only on muse over. Jquery has some very simple functions already set up if you want to use those, otherwise it's not too hard to do with raw JavaScript.

 

I'm replying on my phone at the moment so apologies for no code examples. If you still can't figure it out, let me know and I'll give you some specific code that will help.

 

Denno

Link to comment
Share on other sites

So you want the tooltip to be positioned by the location of the mouse?

 

That will be a bit more involved.. I'm not sure you can do it with just CSS, you'll have to use javascript to constantly update the position of the tooltip div every time the mouse moves, and it's hovered over the button..

Link to comment
Share on other sites

I thought I implemented the tooltip code I developed correctly, but I guess not.

the CSS used on my page is as follows:

<style type="text/css">
table, th, td
{
	word-wrap:break-word;
}

<!--tooltip display code-->
.tooltip span
{
	display:none;	
}
.tooltip:hover span
{
	display:inline;
	position:absolute;
	background:white;
	border:1px solid silver;
	color:gray;
	padding:5px;
	border-radius:10px
}
</style>

This code is nested in a layout table:

<div class='tooltip'>
<img style='width: 50px; height: 50px;' alt='ring' src='...'>
<!--tool tip-->
<span>
<table>
...
</table>
</span>
</div>

Why isn't the tooltip hiding when my mouse is off the div tag, and not preventing the table from resizing?

Link to comment
Share on other sites

No worries at all, we all started somewhere!

 

And also, I've just noticed your signature, very clever! However I'm going to nit-pick on the use of "your"..

 

echo "I will try to help, because your you're still $skill_level , and my skill level is at $my_knowledge";

 

Sorry to be a jerk! :)

 

Denno

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.