dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: image hotspot displays text on hover - How to

  1. #1
    Join Date
    May 2014
    Posts
    2

    image hotspot displays text on hover - How to

    I know how to create the hotspot on an image. Now I need help in coding the display of text on hover.
    I greatly appreciate any advice you can offer. Many thanks,

  2. #2
    Join Date
    Oct 2013
    Posts
    595
    The quickest, easiest way is to just add a title="blah" attribute to each <area> tag. If you want something with a little more "pop" go to:
    http://www.w3schools.com/tags/tryit....ryhtml_areamap

    and paste the following code:
    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Planets</title>
    <style>
    	.msgBox{
    		position:fixed;
    		min-width:120px;
    		margin:15% auto auto 45%;
    		z-index:10;
    		border-radius:5px;
    		border:1px solid #F5F5F5;
    		background-color:#DDD;
    		box-shadow:1px 1px 5px #999;
    		overflow:hidden;
    		display:none}
    	.msgBox ul, .msgBox li{
    		list-style:none;
    		padding:0;
    		margin:0;
    		border:0}
    	.msgBox .title{
    		border-bottom:#AAA solid 1px;
    		padding:5px;
    		background-color:#CCC;
    		font-family:Helvetica, Arial, sans-serif;
    		font-weight:bold;
    		font-size:12px}
    	.msgBox .msgContent{
    		border-top:#F5F5F5 solid 1px;
    		padding:5px;
    		font-family:Times, "Times New Roman", serif;
    		font-size:12px}
    </style>
    <script>
    	function display(mb,m,t){
    		mb.style.display='block';
    		m.innerHTML = t;
    	}
    
    	function hide(mb){
    		mb.style.display='none';
    	}
    </script>
    </head>
    <body>
    
    <div id="msg" class="msgBox">
        <ul>
            <li class="title">Information</li>
            <li id="message" class="msgContent"></li>
        </ul>
    </div>
    
    <img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
    
    <map name="planetmap">
      <area shape="rect" coords="0,0,82,126" href="sun.htm"  onmouseover="display(msg,message,'The Sun')" onmouseout="hide(msg)">
      <area shape="circle" coords="90,58,3" href="mercur.htm" onmouseover="display(msg,message,'The Planet Mercury')" onmouseout="hide(msg)">
      <area shape="circle" coords="124,58,8" href="venus.htm" onmouseover="display(msg,message,'The Planet Venus')" onmouseout="hide(msg)">
    </map>
    
    </body>
    </html>
    Adjust as necessary for your situation.

  3. #3
    Join Date
    May 2014
    Posts
    2

    Smile Thank you Kevin2

    Hi Kevin,
    Thank you for your help. It is much appreciated!!
    : )



    Quote Originally Posted by Kevin2 View Post
    The quickest, easiest way is to just add a title="blah" attribute to each <area> tag. If you want something with a little more "pop" go to:
    http://www.w3schools.com/tags/tryit....ryhtml_areamap

    and paste the following code:
    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Planets</title>
    <style>
    	.msgBox{
    		position:fixed;
    		min-width:120px;
    		margin:15% auto auto 45%;
    		z-index:10;
    		border-radius:5px;
    		border:1px solid #F5F5F5;
    		background-color:#DDD;
    		box-shadow:1px 1px 5px #999;
    		overflow:hidden;
    		display:none}
    	.msgBox ul, .msgBox li{
    		list-style:none;
    		padding:0;
    		margin:0;
    		border:0}
    	.msgBox .title{
    		border-bottom:#AAA solid 1px;
    		padding:5px;
    		background-color:#CCC;
    		font-family:Helvetica, Arial, sans-serif;
    		font-weight:bold;
    		font-size:12px}
    	.msgBox .msgContent{
    		border-top:#F5F5F5 solid 1px;
    		padding:5px;
    		font-family:Times, "Times New Roman", serif;
    		font-size:12px}
    </style>
    <script>
    	function display(mb,m,t){
    		mb.style.display='block';
    		m.innerHTML = t;
    	}
    
    	function hide(mb){
    		mb.style.display='none';
    	}
    </script>
    </head>
    <body>
    
    <div id="msg" class="msgBox">
        <ul>
            <li class="title">Information</li>
            <li id="message" class="msgContent"></li>
        </ul>
    </div>
    
    <img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
    
    <map name="planetmap">
      <area shape="rect" coords="0,0,82,126" href="sun.htm"  onmouseover="display(msg,message,'The Sun')" onmouseout="hide(msg)">
      <area shape="circle" coords="90,58,3" href="mercur.htm" onmouseover="display(msg,message,'The Planet Mercury')" onmouseout="hide(msg)">
      <area shape="circle" coords="124,58,8" href="venus.htm" onmouseover="display(msg,message,'The Planet Venus')" onmouseout="hide(msg)">
    </map>
    
    </body>
    </html>
    Adjust as necessary for your situation.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles