www.webdeveloper.com
Results 1 to 4 of 4

Thread: Help with relative % image maps?

  1. #1
    Join Date
    Mar 2014
    Posts
    2

    Exclamation Help with relative % image maps?

    So, I'm pretty new and please excuse any silly questions.
    I have my image that is set to a width of 93% to accommodate all screen resolutions. Said image needs to have hotspot map links on it to navigate the user to other parts of the webpage.

    The issue I am running into is that, when the image scales according to a specific viewers screen resolution, the hotspots do not respond / follow / adjust. They are moved to other parts of the image and make no sense. Some google searching revealed that I need to set my image into a fixed position via pixels and not percents. How can I accommodate all screen resolutions that way? More googling said there is a JQuery plug-in that can help me, but I cannot figure out how to use it and get it working properly.

    Can anyone help me with this, please? :[
    This website is not live yet so I have to remove all related content from the coding below. Other than changed image URLs and titles, the coding is exactly what I have thus far:

    Code:
    <style type="text/css">
    body,td,th {
    	color: #e51827;
    }
    body {
    	background-color: #000;
    	style="height:100%"
    </style>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Title_Here</title>
    </head>
    
    
    <body>
    <center>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
        
        <center>
        <img src="../images/bannerspace.jpg" width="93%"/>
        <p>
        <img src="../images/bannerspace.jpg" width="93%"/>
        <P>
        <img src="../images/bannerspace.jpg" width="93%"/>
        <P>
        <img src="../images/bannerspace.jpg" width="93%"/>
        </P>
    </center>
        </td>
        
        <td>
        <img src="../images/mainimage.jpg" width="93%" usemap="#Map" border="0"/>   
        </td>
      </tr>
    
      <tr>
        <td>&nbsp;</td>
        <td>
    <center>
              <!-- Counter Code START --><img src="http://www.e-zeeinternet.com/count.php?page=1049534&style=LED_r&nbdigits=5&reloads=1"  border="0" ><br><!-- Counter Code END -->
    </center>
        </td>
      </tr>
    </table>
    </center>
    
    <map name="Map" id="Map">
      <area shape="rect" coords="5,199,42,361" href="index.html" target="_self" alt="home" />
      <area shape="rect" coords="103,418,286,470" href="https://www.facebook.com" target="new" alt="facebook" />
      <area shape="rect" coords="368,458,563,495" href="contact.html" target="_self" alt="contact" />
      <area shape="rect" coords="712,190,744,377" href="enter.html" target="_self" alt="enter" />
      <area shape="rect" coords="114,127,297,178" href="availability.html" target="_self" alt="availability" />
      <area shape="rect" coords="436,207,577,252" href="currentprojects.html" target="_self" alt="currentprojects" />
    </map>
    </body>

  2. #2
    Join Date
    Mar 2012
    Posts
    1,729
    The answer is: An image map is not suitable for this purpose. Do not use an image map for your primary navigation in a responsive page. It does not work.

  3. #3
    Join Date
    Mar 2014
    Posts
    2
    Quote Originally Posted by jedaisoul View Post
    The answer is: An image map is not suitable for this purpose. Do not use an image map for your primary navigation in a responsive page. It does not work.
    Thanks for the answer but can you please provide me with a work-around?

  4. #4
    Join Date
    Mar 2012
    Posts
    1,729
    There is no work-around, but you can achieve a similar effect with a different functionality. E.g.:
    1. Copy the main image and crop it to include only one highlight area. Save it as, say, "home.jpg".
    2. Repeat 1. for the other highlights. Call them "about.jpg", "work.jpg" & "contact.jpg" (or whatever is appropriate...).

    You now have a set of graphics to build the nav.

    In the CSS:
    3. Use position absolute (this allows you to overlay divs etc...).
    4. Put the main graphic in the background of a parent DIV.
    5. Create child DIVs to position each "hot spot" w.r.t. the parent DIV.

    E.g. To create a full width graphical menu in the top 20% of the page which is divided laterally into four hot spots, use something like:
    Code:
    * {
    margin: 0;
    padding: 0;
    border: 0;
    }
    body {
    position: relative;
    width: 100%;
    height: 100%;
    }
    #parent {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 20%;
    }
    #home {
    position: absolute;
    top: 0;
    left: 0;
    width: 25%;
    height:100%;
    }
    #about {
    position: absolute;
    top: 0;
    left: 25%;
    width: 25%;
    height:100%;
    }
    #work {
    position: absolute;
    top: 0;
    left: 50%;
    width: 25%;
    height:100%;
    }
    #contact {
    position: absolute;
    top: 0;
    left: 75%;
    width: 25%;
    height:100%;
    }
    In the HTML use something like:
    Code:
    <div id="parent">
    <div id="home">
    <a href="index.html"><img src="home.jpg" alt="home"></a>
    </div>
    <div id="about">
    <a href="about.html"><img src="about.jpg" alt="about us"></a>
    </div>
    <div id="work">
    <a href="work.html"><img src="work.jpg" alt="work"></a>
    </div>
    <div id="contact">
    <a href="contact.html"><img src="contact.jpg" alt="contact"></a>
    </div>
    </div>
    I have not tested this code, so it may need some tweaking, but it gives the general idea.
    Last edited by jedaisoul; 04-01-2014 at 05:34 AM.

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