Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8636125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:09:00+00:00 2026-06-12T10:09:00+00:00

I have some code here trying to display a picture, and then when mousing

  • 0

I have some code here trying to display a picture, and then when mousing over certain parts of it displaying a caption.

I have it working with text, but not the picture. I have barely used css ever, but fairly more familiar with html.
What is wrong here and how can i get it to work? ideally it should work the same as the word ‘sword.’

<html>
<body background="Gray.jpeg"> 

<style type="text/css">
ul, li {
    list-style: none;
}

ul.bindel {
    position: relative;
    float: center;
    width: 514px;
    height: 528px;
    /* background: url(Gladiators.jpeg) no-repeat; */
    background: url(http://4.bp.blogspot.com/_XJDCOO_PcIc/TRknvnbiNNI/AAAAAAAAEDg/6KPijl4Dtl0/s1600/Gladiators.jpg) no-repeat;
    border: 1px solid #000000;
}

ul.bindel li a span.caption {
    display: none;
    position: absolute;
    top: 20px;
    left: 50px;
    width: 270px;
    padding: 5px;
}

ul.bindel li a:hover {
    display: inline;
    cursor: pointer;
}

ul.bindel li a:hover span.caption {
    display: block;
    border: 3px solid #333333;
    color: white;
    font-size: 17px;
    background: #330000;
    text-align: left;
}

a.bl {
    width: 257px;
    height: 264px;
    margin-top: 0px;
    margin-left: 0px;
}

a.bl:hover {
    border: 3px solid #000000;
}

a.br {
    width: 257px;
    height: 264px;
    margin-top: 0px;
    margin-left: 258px;
}

a.br:hover {
    border: 3px solid #000000;
}

a.bind {
    position: relative;
}

a.bind span {
    display: none;
    position: absolute;
    top: 20px;
    left: 50px;
    width: 270px;
    padding: 5px;
}

a.bind:hover {
    display: inline;
    cursor: pointer;
}

a.bind:hover span {
    display: block;
    border: 3px solid #333333;
    color: white;
    font-size: 17px;
    background: #330000;
    text-align: left;
}
</style>
<center><br>
<a class="bind">Sword<span>The gladiators would use this in close combat.</span></a><br><br><br><br>

<ul class="bindel">
    <li><a id="bl"><span class="caption">Left Side</span></a></li>
    <li><a id="br"><span class="caption">Right side</span></a></li>
</ul>

</center></body>
</html>  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:09:02+00:00Added an answer on June 12, 2026 at 10:09 am

    you can achieve that kind of functionality using an html ImageMap and some javascript.

    I can’t help but thinking that this is a rough-n-nasty implementation, in that it breaks when used with screen resolutions that differ to mine (1366×768). I think you could probably get over this, by placing both the image and the captions inside the same div. You could then make the position of the captions relative, instead of absolute. Then, your left and top co-ords would be relative to the container that holds the image, rather than relative to the top left of the browser window. Doing this would probably mean that the code would work on different sized screens, also it would continue to work if the image was no-longer centered on the page.

    The image-map co-ords were determined by drawing simple polygons around the sword and shield, keeping track of their x/y co-ords, before entering them into the html.

    Just change the src for the image (I used a local copy, sick of waiting to load each iteration of the test)

    Enjoy!

    <html>
    <head>
    <style type="text/css">
    a.bind {
        position: relative;
    }
    
    a.bind span {
        display: none;
        position: absolute;
        top: 20px;
        left: 50px;
        width: 270px;
        padding: 5px;
        border: 3px solid #333333;
        color: white;
        font-size: 17px;
        background: #330000;
        text-align: left;
    }
    
    a.bind:hover {
        display: inline;
        cursor: pointer;
    }
    
    a.bind:hover span {
        display: block;
    }
    
    .caption
    {
        display: none;
        border: 3px solid #333333;
        color: white;
        font-size: 17px;
        background: #330000;
        text-align: left;
        position: absolute;
        width: 270px;
    }
    
    #shieldCapt
    {
        left: 920px;
        top: 380px;
    }
    
    #swordCapt
    {
        left: 600px;
        top: 480px;
    }
    </style>
    
    <script>
    function myHover(element)
    {
        var hoveredElement = element;
        var tgt = hoveredElement.getAttribute('tgt');
        tgt = document.getElementById(tgt);
        tgt.style.display = 'inline';
    }
    
    function myLeave(element)
    {
        var hoveredElement = element;
        var tgt = hoveredElement.getAttribute('tgt');
        tgt = document.getElementById(tgt);
        tgt.style.display = 'none';
    }
    </script>
    
    </head>
    
    <body> 
    <center>
    <br>
    <a class="bind">Sword<span>The gladiators would use this in close combat.</span></a>
    <br>
    <br>
    <br>
    
    <img src='img/gladiators.png' usemap='#imgMap'>
    <map name="imgMap">
        <area id='swordPoly' shape="polygon" tgt='swordCapt' onmouseover='myHover(this);' onmouseout='myLeave(this);' coords="227,307,261,309, 339,354, 328,371, 240,331, 227,307">
        <area id='shieldPoly' shape="polygon" tgt='shieldCapt' onmouseover='myHover(this);' onmouseout='myLeave(this);' coords="413,245, 475,215, 473,200, 511,307, 526,388, 497,408, 454,422, 422,339, 413,245">
    </map>
    
    <br>
    <span class='caption' id='shieldCapt'>The gladiators would defend themeselves with this.</span>
    <span class='caption' id='swordCapt'>The gladiators would use this in close combat.</span>
    
    </center>
    </body>
    </html>  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to reduce some code here. I will explain how I have
I have some code here that uses bitsets to store many 1 bit values
I have some code here which works perfectly in firefox but not in chrome
I have some code here to call minizip(), a boilerplate dirty renamed main() of
I have some code that is using SyncEnumerator. As you can see here ,
I have some code as shown below: - (IBAction)startButtonPressed:(id)sender { statusText.text = @Processing...; //here
I'm writing some code here, and I'm having a had time. I have a
I have this loop for (it= someCollection.iterator; it.hasNext(); ) { //some code here }
Just some example code here, but I have lists of strings that I want
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.