Solved

Image Hot Spot in CSS

Posted on 2003-10-25
7
643 Views
Last Modified: 2006-11-17
How do I put a "hot spot" on a graphic in a CSS? ( Only a small portion of the graphic will be the link, not the entire graphic)   I do NOT want the image src to be included in the HTML body.  All info has to be put into the CSS, with the exception of the
 
<a class="imgmap">
<AREA SHAPE='rect' COORDS='182,94,277,128' HREF='http://www.moggies-and-more.com/index1.html' ALT='Enter'>
</a>

tag that is in the HTML body.
 
( I know this HTML setup is wrong, just clarifying my question)




CSS example:

a.imgmap{

background: transparent url(anienter2.gif);
margin-top:-150px;
width: 416;
height: 273px;
position:absolute;
right:0px;
repeat:no-repeat;
 
}
0
Comment
Question by:kattz7
  • 3
  • 3
7 Comments
 
LVL 6

Assisted Solution

by:DoppyNL
DoppyNL earned 35 total points
ID: 9625222
you could position (with absolute positioning) another block over the first one with a much smaller image. and put the link in there.
0
 
LVL 11

Expert Comment

by:Zontar
ID: 9625784
That's the only way you're going to be able to do it -- a MAP has to be assigned to an IMG element. You can't use an image map with a background image any more than you can use one with a background colour -- there's no element there for it to be assigned to.

(In theory a MAP can also be assigned to an OBJECT element, but I know of no browser which supports this yet.)
0
 

Author Comment

by:kattz7
ID: 9627907
Thank you very much for your responses.   However, I was wondering if this
could this not be obtainable?


HTML:

<a class="imgmap">
</a>

 
CSS:

a.imgmap{

background: transparent url(anienter2.gif);
AREA SHAPE:rect;
COORDS:182,94,277,128;
HREF:http://www.moggies-and-more.com/index1.html (ALT=Enter);
margin-top:-150px;
width: 416;
height: 273px;
position:absolute;
right:0px;
repeat:no-repeat;
 
}
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 11

Accepted Solution

by:
Zontar earned 100 total points
ID: 9630407
Nope.

That's not what CSS is for. It controls the formatting and presentation of HTML structural elements; it's not some sort of magical replacement for them.

Note that I said "structural" -- the FONT tag wasn't a structural element, why is exactly why it was deprecated and replaced with CSS. Only logical elements can be made into hyperlinks.

You might want to look into SVG, where you can create an element consisting of an arbitrary shape and then turn *that* into a link.

Why don't you want to use an IMG tag, anyway?
0
 

Author Comment

by:kattz7
ID: 9630743
Thank you so much for your input.  

Shucks.....oh well, guess I will have to forget this idea.
My CSS class doesn't start until next week and I really wanted to have a CSS page ready
according to my preferences.

The reason I don't want to use an IMG tag:

My website is approximately 50 pages.   If there is ever a time that I would like to change the IMG, that I wanted to put the "hot spot",  I only wanted to change the one CSS page and not the entire site.


Have a fabulous day/evening.  Again, many thanks.

Kim

0
 
LVL 11

Expert Comment

by:Zontar
ID: 9630993
Use a serverside include in your pages and put the IMG tag in that. Then, should you wish to change the image, you need change only the include file.

There are several different ways to do includes, depending on what webserveryour site uses and what programming environments are installed on it. Here's an example:

Source of /includes/myfile.inc:

<img src="/images/myimg.jpg" width="415" height="125" border="0" usemap="#mymap">

<map name="mymap">
  <area shape="rect" coords="182,94,277,128" href="index1.html" alt="Enter" title="Enter">
</map>

Then in your HTML pages use

<!-- include virtual="/includes/myfile.inc" -->

That's *not* a literal example, as the specifics will deifinitely vary according to the server being used, your directory structure, etc., but that's the basic idea. SSI's are a very handy and powerful tool, and it'd be well worth the time spent learning how to use them.
0
 

Author Comment

by:kattz7
ID: 9631189

Thank you so very much.  If there was a "Triple A" to be given, I would give it to you for your generous time in helping me and the informative answers.

I wondered what SSI meant and how it fit into web design.
I will register for that class for next term.  I can hardly wait to learn it.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to handle $x_amount to payment gateway in php - stumped. 14 40
Where can I ask about my ASP.NET MVC project? 6 45
Company website 6 30
Wordpress Security 29 49
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 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