Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a cursor [with CSS] on an image map area

Tags:

css

Is there any way to set a cursor on an area element with CSS? It seems not. This code appears to do nothing at all.

CSS

area {cursor: help;}

HTML

<img src="blah.png" width="800" height="550" alt="Blah" usemap="#blah-map">
<map name="blah-map">
    <area shape="rect" coords="104,86,210,113" href="okgo.htm" alt="OK Go">
</map>

The best hack I have been able to come up with is to absolutely position a link on top of that area, and give it the cursor style.

like image 791
Bart Avatar asked May 08 '12 16:05

Bart


People also ask

How do I customize my cursor in CSS?

Answer: Use the CSS cursor property You can define a custom cursor using the CSS cursor property. The cursor property takes the comma-separated list of user-defined cursors value followed by the generic cursor. First of all create cursor image and save it with the extension .

How do you get a cursor in CSS?

Apply the CSS property cursor:pointer; to the elements. (This is the default style when a cursor hovers over a button.) Apply the CSS property cursor:url(pointer. png); using a custom graphic for your pointer.

How do you create an area in an image map?

The <area> tag defines an area inside an image map (an image map is an image with clickable areas). <area> elements are always nested inside a <map> tag. Note: The usemap attribute in <img> is associated with the <map> element's name attribute, and creates a relationship between the image and the map.

What is CSS cursor property?

The cursor property of CSS allows you to specify the type of cursor that should be displayed to the user. One good usage of this property is in using images for submit buttons on forms. By default, when a cursor hovers over a link, the cursor changes from a pointer to a hand.


1 Answers

I recently had an issue with a css cursor displaying in firefox correctly, but not in chrome or safari.

Long story short, I ended up needed to set display:block; on the area tag. Either my base css, or the browser defaults the tag to display:none;

This was the quick test case I created (check it out HERE)

<img usemap="#map" src="http://i.imgur.com/9EcEvkn.jpg" height="120" width="100" />
<map name="map" id="map">
<area shape="rect" coords="0,0,120,100" href="#" />
</map>

area {
    cursor: crosshair;
    display:block;
}

Hopefully this helps someone.

like image 132
toazron1 Avatar answered Sep 28 '22 21:09

toazron1