Solved

problem positioning a hotspot over an image

Posted on 2012-12-20
4
283 Views
Last Modified: 2012-12-21
I'm having a problem positioning a hotspot (should be a rectangle 230px wide by 88px high) over an image in a web page header.  Rather than appearing over top of the image using the coordinates defined in the CSS, it displays right before the image.  What am I doing wrong?

Here's what I have:

HTML

<div class="art-Header">
    <jdoc:include type="modules" name="Search-box" />
    <div class="art-Header-jpeg">
            <a href="http://www.agro-k.com/index.php?option=com_alfcontact&Itemid=148" class="hotspot" title="Contact Us">&nbsp</a>
      </div>
</div>

CSS

div.art-Header-jpeg
{
      position: absolute;
      z-index:-1;
      top: 30;
      left: 0;
      width: 906px;
      height: 150px;
      background-image: url('../images/Header.png');
      background-repeat: no-repeat;
      background-position: center center;
}


div.art-Header-jpeg .hotspot a
{
    width: 130px; height: 88px;
    position: absolute;
    top: 567px; /* Top coord of hotspot (relative to parent, bottom: 20px is also valid) */
    left: 44px; /* Left coord of hotspot (right: 20px is also valid); */
      z-index:100;
}
0
Comment
Question by:mycomac
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Mrunal
ID: 38711893
Hi mycomac,
Can you share link for this problem you are facing, so that we can get bette clear picture what you want.
0
 
LVL 43

Assisted Solution

by:Chris Stanyon
Chris Stanyon earned 500 total points
ID: 38712870
OK. A few things wrong with your code. You anchor has a class of hotspot, but your CSS is trying to style an Anchor within .hotspot. Your rule should be :

div.art-Header-jpeg a.hotspot { ... }

You're setting the top coordinate of the Hotspot to 567px but the parent container is only 150px deep so you're effectively setting it out of sight.

z-index doesn't come into it.

Have a look at this fiddle. I haven't included images, but hopefully you'll get the gist.

http://jsfiddle.net/ChrisStanyon/zY85B/
0
 

Author Comment

by:mycomac
ID: 38713020
I made the changes (I think) that you suggested, but still don't have the hotspot positioned over the Name/address area of the header.  I've left it for you to see at http://www.agro-k.com/

The hotspot is located right below the search box.

here is the html and css I have

HTML
<div class="art-Header">
    <div class="art-Header-jpeg">
        <a href="http://www.agro-k.com/index.php?option=com_alfcontact&Itemid=148" class="hotspot" title="Contact Us">&nbsp;</a>
    </div>
</div>

CSS
div.art-Header-jpeg
{
      position: absolute;
      z-index:-1;
      top: 30;
      left: 0;
      width: 906px;
      height: 150px;
      background-image: url('../images/Header.png');
      background-repeat: no-repeat;
      background-position: center center;
}
div.art-Header-jpeg a.hotspot
{
    width: 130px; height: 88px;
    position: relative;
    top: 44px; /* Top coord of hotspot (relative to parent, bottom: 20px is also valid) */
    left: 567px; /* Left coord of hotspot (right: 20px is also valid); */
      z-index:100;
}
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 38713067
OK. You're nearly there. You need to set your A tag to display as a block element, so add display:block to your CSS.

div.art-Header-jpeg a.hotspot {
   display:block;
   width: 130px;
   height: 88px;
   position: relative;
   top: 44px;
   left: 567px;
} 

Open in new window

Your measurements seem to be slightly off, so you might want to add a border to the anchor tag just to make it easier (border: 1px solid red;). Don't forget to remove it once you've got the positioning right.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iOS 10 iPad Zoom and acroll 4 54
CSS change width browser switches to mobile view 2 53
Message not shown 5 33
insert text field data into html script 13 25
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now