Related
I'm not a programmer/developer. I tried to put this code on the sidebar of my WordPress website, with the HTML widget. It is working on a page (with the HTML block), but not on the sidebar. I tried with two different themes. Anyone has any idea on how to make it work/a possible alternative?
<img src="wp-content/uploads/2022/05/Site2.png" usemap="#image-map" alt="test">
<map name="image-map" id="test-imgmap">
<area target="_blank" alt="test" title="" href="example1" coords="500,398,73,481" shape="rect">
<area target="_blank" alt="test" title="" href="example2" coords="71,493,493,563" shape="rect">
<area target="_blank" alt="test" title="" href="example3" coords="71,570,495,641" shape="rect">
</map>
<img src="images/imagemap.png" width="600" height="100" border="0" usemap="#map" />
<map name="map">
<!-- #$-:Image map file created by GIMP Image Map plug-in -->
<!-- #$-:GIMP Image Map plug-in by Maurits Rijk -->
<!-- #$-:Please do not edit lines starting with "#$" -->
<!-- #$VERSION:2.3 -->
<!-- #$AUTHOR:Eric -->
<area shape="rect" coords="2,2,98,97" onclick="scrollto1()" style="cursor: pointer;" />
<area shape="rect" coords="102,3,202,95" onclick="scrollto2()" style="cursor: pointer;" />
<area shape="rect" coords="208,3,307,95" onclick="scrollto3()" style="cursor: pointer;"/>
<area shape="rect" coords="315,5,409,98" onclick="scrollto4()" style="cursor: pointer;"/>
<area shape="rect" coords="413,6,502,97" onclick="scrollto5()" style="cursor: pointer;"/>
<area shape="rect" coords="507,4,597,97" onclick="scrollto6()" style="cursor: pointer;"/>
</map>
The image map is clickable in all browsers except Internet Explorer 10. I am wondering if there is some way to get things working in Internet Explorer.
I have updated your code, its working now :)
you do not have the area self closing, and you were missing href="#" and style is not required at all :)
check the fiddle in case you want to check
Link : http://jsfiddle.net/MarmeeK/bD4s7/
<img src="http://images5.fanpop.com/image/photos/30600000/Template-800-x-100-pippy-and-jezzis-world-of-purdy-mindedness-30664157-800-100.jpg" width="600" height="100" border="0" usemap="#maps" alt="" />
<map name="maps">
<area shape="rect" coords="2,2,98,97" onclick="scrollto1()" style="cursor: pointer;" >
<area shape="rect" coords="102,3,202,95" href="#" >
<area shape="rect" coords="208,3,307,95" href="#" >
<area shape="rect" coords="315,5,409,98" href="#" >
<area shape="rect" coords="413,6,502,97" href="#" >
<area shape="rect" coords="507,4,597,97" href="#" onclick="javascript:alert('hi');" >
</map>
I tried to fix response div position fixed:
HTML is:
<div id="response">
<table width="100%" cellspacing="5" style="background-image:url(images/bg.gif); background-repeat:no-repeat; width:100%;">
<tr>
<td class="clock" colspan="2"><?php include'scripts/clock.html'; ?></td>
</tr>
</table>
</div>
<div>
<img src="images/map.gif" border="0" usemap="#Msj_Map" alt="map" class="map" />
<map name="Msj_Map" id="Msj_Map">
<area id="8" shape="poly" coords="436,141,486,141,486,207,436,206" />
<area id="1" shape="poly" coords="163,148,163,170,159,170" />
<area id="2" shape="poly" coords="163,207,153,207,159,173,163,173" />
<area id="189" shape="poly" coords="198,281,199,307,161,307,161,282" />
<area id="190" shape="poly" coords="198,309,199,333,161,334,161,309" />
<area id="165" shape="poly" coords="540,230,570,230,577,236,577,271,540,271" />
<area id="40" shape="poly" coords="384,1156,419,1156,419,1180,383,1180" />
<area id="39" shape="poly" coords="422,1156,458,1156,458,1180,422,1181" />
<area id="54" shape="poly" coords="321,1109,353,1109,359,1116,360,1159,321,1159" />
<area id="29" shape="poly" coords="356,1235,387,1235,387,1274,356,1274" />
<area id="22" shape="poly" coords="390,1277,457,1277,457,1311,453,1315,390,1315" />
<area id="23" shape="poly" coords="321,1277,387,1277,387,1315,321,1315" />
<area id="24" shape="poly" coords="319,1277,319,1316,252,1316,252,1277" />
</map>
</div>
like http://www.noobcube.com/wp-content/uploads/demos/062709-fixed-header-footer/demo/
I used its logic but during implementation I found that <map> tag does not play its part with other elements because <map> draws just over an image and therefore does not support overflow:scroll. But <map> is the key element in my code.
May be there is some other solution to fix it.
After a long struggle i catch z-index and create css for response and <map> divs:
.calculator{
z-index:1000;
position:fixed;
top:0px;
}
.map-wrap{
margin-top:350px;
}
<div id="response" class="calculator">
<table width="100%" cellspacing="5" style="background-image:url(images/bg.gif); background-repeat:no-repeat; width:100%;">
<tr>
<td class="clock" colspan="2"><?php include'scripts/clock.html'; ?></td>
</tr>
</table>
</div>
<div class="map-wrap">
<img src="images/map.gif" border="0" usemap="#Msj_Map" alt="map" class="map" />
<map name="Msj_Map" id="Msj_Map">
<area id="8" shape="poly" coords="436,141,486,141,486,207,436,206" />
<area id="1" shape="poly" coords="163,148,163,170,159,170" />
<area id="2" shape="poly" coords="163,207,153,207,159,173,163,173" />
<area id="189" shape="poly" coords="198,281,199,307,161,307,161,282" />
<area id="190" shape="poly" coords="198,309,199,333,161,334,161,309" />
<area id="165" shape="poly" coords="540,230,570,230,577,236,577,271,540,271" />
<area id="40" shape="poly" coords="384,1156,419,1156,419,1180,383,1180" />
<area id="39" shape="poly" coords="422,1156,458,1156,458,1180,422,1181" />
<area id="54" shape="poly" coords="321,1109,353,1109,359,1116,360,1159,321,1159" />
<area id="29" shape="poly" coords="356,1235,387,1235,387,1274,356,1274" />
<area id="22" shape="poly" coords="390,1277,457,1277,457,1311,453,1315,390,1315" />
<area id="23" shape="poly" coords="321,1277,387,1277,387,1315,321,1315" />
<area id="24" shape="poly" coords="319,1277,319,1316,252,1316,252,1277" />
</map>
</div>
and get rid of it. :)
Thanks all.
Wrap a div around <img> and <map>. Like so :
<div class="map-wrap">
<img ... >
<map>
...
</map>
</div>
And add css :
.map-wrap {position:relative;}
For the other 2 answers <map> cannot be replaced by <div>
The <map> tag is used for defining an image map. Which is the image divided in to clickable areas or mouse sensitive areas.
Better using a <div> instead <map>.
Tell in CSS that the <div> must have a fixed position and everything should works fine.
The code below works great in all modern browsers. I'm using a transparent gif as an image map so I can swap different keyboard images/divs below it to make the keyboard appear to be playable. In IE8 everything functions, but I get that ugly icon in the top left corner. Any ideas?
<div id="pressed-keys" class="kb-none">
<div id="kb-audio"></div>
</div>
<div id="mapped-keys" class="hide">
<img src="keyboard-overlay.gif" border="0" width="316" height="250" usemap="#keyboard-map" border="0" alt="Keyboard" class="alpha-0" style="background:transparent;border:0;" />
<map name="keyboard-map" id="keyboard-map">
<area id="key-1" class="kb1-C2" shape="poly" coords="77,155,88,149,157,189,165,182,213,208,193,229" href="#" alt="C">
<area id="key-2" class="kb2-C2s" shape="poly" coords="97,138,89,142,89,149,157,188,167,180,155,167" href="#" alt="C#">
<area id="key-3" class="kb3-D2" shape="poly" coords="111,138,105,141,155,166,168,179,166,182,214,208,232,191,184,168,182,170" href="#" alt="D">
<area id="key-4" class="kb4-D2s" shape="poly" coords="113,131,113,137,181,168,191,163,179,151,120,127" href="#" alt="D#">
<area id="key-5" class="kb5-E2" shape="poly" coords="233,190,186,168,192,163,180,150,129,129,131,129,247,174" href="#" alt="E">
<area id="key-6" class="kb6-F2" shape="poly" coords="248,173,259,161,215,145,209,149,140,125,133,129" href="#" alt="F">
<area id="key-7" class="kb7-F2s" shape="poly" coords="140,125,141,117,146,115,205,134,215,144,208,149" href="#" alt="F#">
<area id="key-8" class="kb8-G2" shape="poly" coords="260,160,270,149,226,135,224,137,205,133,216,144" href="#" alt="G">
<area id="key-9" class="kb9-G2s" shape="poly" coords="223,136,155,116,156,110,160,107,219,124,228,133" href="#" alt="G#">
<area id="key-10" class="kb10-A2" shape="poly" coords="221,124,229,133,228,135,270,149,278,139,237,127,236,127" href="#" alt="A">
<area id="key-11" class="kb11-A2s" shape="poly" coords="169,108,170,103,174,101,231,115,239,123,236,127" href="#" alt="A#">
<area id="key-12" class="kb12-B2" shape="poly" coords="278,138,286,129,234,117,240,123,238,126" href="#" alt="B">
<area id="key-13" class="kb13-C3" shape="poly" coords="285,128,233,115,230,114,182,102,185,100,250,114,253,111,291,120" href="#" alt="C">
<area id="key-14" class="kb14-C3s" shape="poly" coords="249,113,186,99,186,94,189,92,245,103,252,110" href="#" alt="C#">
<area id="key-15" class="kb15-D3" shape="poly" coords="291,119,296,113,260,105,257,106,247,104,253,110" href="#" alt="D">
<area id="key-16" class="kb16-D3s" shape="poly" coords="257,105,244,102,196,92,196,89,201,86,253,95,261,102" href="#" alt="D#">
<area id="key-17" class="kb17-E3" shape="poly" coords="296,111,301,106,256,97,262,102,260,104" href="#" alt="E">
</map>
</div>
I've got a problem with image map HTML.
Working example with no style and no js on:
http://www.download.lagunawebdesign.pl/bug/
<img src="http://www.download.lagunawebdesign.pl/bug/Bez-nazwy-2.png" width="242" height="347" alt="Planets" usemap="#planetmap" />
<map id="planetmap" name="planetmap">
<area shape="poly" coords="31,37,31,68,47,68,47,54,51,54,51,38" title="1" alt="" href="#" />
<area shape="poly" coords="29,48,23,47,23,42,6,42,6,57,13,58,15,67,31,66,30,49" title="2" alt="" href="#" />
<area shape="poly" coords="32,99,31,131,46,131,47,117,51,116,51,99" title="3" alt="" href="#" />
<area shape="poly" coords="32,163,32,196,46,194,46,180,51,180,52,164,31,163,31,196,47,195,46,180,52,180,52,163" title="4" alt="doesnt work" href="#" />
<area shape="poly" coords="32,227,31,258,47,259,47,245,52,245,52,227" title="5" alt="" href="#" />
<area shape="poly" coords="121,297,121,316,153,317,153,302,139,301,139,296" title="6" alt="" href="#" />
<area shape="poly" coords="190,209,191,226,210,227,211,195,195,195,196,209" title="7" alt="" href="#" />
<area shape="poly" coords="5,17,5,0,51,0,51,18" title="8" alt="" href="#" />
</map>
Only fourth area doesnt work properly. On Firefox or Opera is not clickable, Firebug shows good area, but on hover cursor doesnt change (only really small peace close to area on the right side is clickable). On IE works fine.
I really do not know how to fix it.
All coords are putted by customer in CMS, some coords doesnt work (like 3/500).
Looks to me that there are just too many coords in the fourth area. I tried
coords="32,163,31,196,46,194,46,180,51,180,52,164" and it seemed to work for me in Firefox and Opera. Hope this helps!
Just change 164,31,163,31 to 164,31. It will looks almost same, but it's works.