html, cannot do onhover for an image map areas - html
I'm trying to apply a filter to an images map area, when it is hovered on. It displays the tooltip on the correct area, but nothing changes when I hover on it.I've tried to use z-index but that didn't help either.
html code:
<div>
<img src={imagesource} usemap="#image-map">
</img>
<map name="image-map">
<area id="area1" style={{backgroundColor:"black", zIndex:"3"}} target="_self" alt="siauliai" title="siauliai" href="" coords="2087,1394,1974,1821,1379,1890,1312,1760,1396,1540,1311,1445,1334,1383,1328,1355,1592,1349" shape="poly"/>
<area id="area2" target="_self" alt="panevezys" title="panevezys" href="" coords="2036,1844,2266,1911,2396,1715,2851,1703,2940,1585,2412,1327,2115,1411,2053,1535,2042,1636" shape="poly"/>
<area id="area3" target="_self" alt="utena" title="utena" href="" coords="2379,1748,2389,1850,2676,2158,2907,2181,2884,2007,3339,2046,3283,1788,2974,1619,2766,1726,2516,1729" shape="poly"/>
<area id="area4" target="_self" alt="vilnius" title="vilnius" href="" coords="3173,2975,2933,2601,3124,2269,3364,2064,2940,2021,2912,2212,2678,2212,2403,1887,2240,1972,2481,2339,2276,2686,2671,2657,2523,2827,2558,2961" shape="poly"/>
<area id="area5" target="_self" alt="alytus" title="alytus" href="" coords="1781,2660,2523,3197" shape="rect"/>
<area id="area6" target="_self" alt="marijamp" title="marijamp" href="" coords="1314,2184,1753,2198,1859,2601,1583,2827,1293,2693" shape="poly"/>
<area id="area7" target="_self" alt="Klaipeda" title="Klaipeda" href="" coords="671,1510,1074,1347,855,1651,1138,2174,473,2033" shape="poly"/>
<area id="area8" target="_self" alt="telsiai" title="telsiai" href="" coords="883,1663,989,1804,1322,1755,1371,1564,1307,1352,1201,1324,1124,1338,975,1515" shape="poly"/>
<area id="area9" target="_self" alt="taurage" title="taurage" href="" coords="1703,2073,1689,2137,1159,2172,1032,2002,1004,1826,1279,1762,1435,2024" shape="poly"/>
<area id="area10" target="_self" alt="kaunas" title="kaunas" href="" coords="1774,2146,1951,2641,2226,2549,2424,2330,2191,1913,1611,1870,1428,1899,1477,2012,1682,2033" shape="poly"/>
</map>
css code:
area{
display:block;
}
#area1:hover {
background:black;
opacity: 0.5;
}
#area2:hover {
background:black;
opacity: 0.5;
}
#area3:hover {
background:black;
opacity: 0.5;
}
#area4:hover {
background:black;
opacity: 0.5;
}
#area5:hover {
background:black;
opacity: 0.5;
}
#area6:hover {
opacity: 0.5;
background:black;
}
#area7:hover {
opacity: 0.5;
background:black;
}
#area8:hover {
opacity: 0.5;
opacity:0.2;
}
I don't know the solution. But I see you can just define area:hover single time instead of repeating it. Or give them a single class and then use .classname:hover. This way also, it only effects the area you hovered instead of effecting all.
Sorry I don't have the answer but this was a little productivity tip.
Related
How to change image map coords with media query
I have an image map and I made a media query so that the image changes at a specific width. How can I write code so that I can change the coords for the new image? HTML <img src="../images/journey-final-01.jpg" alt="journey" usemap="#journeymap"> <map id="map_ID" name="journeymap"> <area target="" alt="flag1" title="Milestone 1" href="" coords="1356,644,1482,809" shape="rect"> <area target="" alt="flag2" title="Milestone 2" href="" coords="808,595,900,710" shape="rect"> <area target="" alt="flag3" title="Milestone 3" href="" coords="1361,320,1431,405" shape="rect"> <area target="" alt="flag4" title="Milestone 4" href="" coords="1124,161,1190,248" shape="rect"> <area target="" alt="cap" title="DDA" href="" coords="1173,110,1359,5" shape="rect"> </map> CSS body img{ width: 100vw; height: 100vh; } #media only screen and (max-width: 600px) { body img { content: url("../images/journey-mobile-01.jpg"); } }
Image map not working
I have an image map and my link is not clickable on my image. Here is my map/image code: <map name="map"> <area shape="rect" coords="208, 76, 229, 101" href="link here"> </map> <img id="himg" usemap="#map" src="img here"> Here is "himg" css: #himg { position:relative; width:781px; height:245px; margin:0 auto; z-index: -10; } At first I had the image before the map, but then switched it so the map comes first, but that did not make anything clickable.
Unable to highlight area map
I am trying to create an area map but I want to highlight the area of the newspaper like border in red color, but I am not getting how to do it . I am creating the area map as follow : <div> <img src="http://cantact104.com/wp-content/plugins/eNewsPaper/menu-pages/newspaper/01_17.jpg" id="photo" usemap="#planetmap"> </div> <map name="planetmap"> <area shape="rect" style="cursor:pointer;" coords="360,6.3,976.5,827.1" target="_blank" onclick="return hello(1);" alt="Sun" onmouseover="borderit(this,'black')" onmouseout="borderit(this,'white')"><area shape="rect" style="cursor:pointer;" coords="0,407.7,667.8,826.2" target="_blank" onclick="return hello(2);" alt="Sun" onmouseover="borderit(this,'black')" onmouseout="borderit(this,'white')"><area shape="rect" style="cursor:pointer;" coords="0,1.8,362.7,404.1" target="_blank" onclick="return hello(3);" alt="Sun" onmouseover="borderit(this,'black')" onmouseout="borderit(this,'white')"><area shape="rect" style="cursor:pointer;" coords="0,826.2,976.5,1543.5" target="_blank" onclick="return hello(4);" alt="Sun" onmouseover="borderit(this,'black')" onmouseout="borderit(this,'white')"></map> function borderit function borderit() { alert('dd'); jQuery(this).css("background-color","yellow"); } </script>
I suggest you to remove your borderIt function and onmouseover/onmouseout attributes because it's complicated to manage with this kind of elements. Simply use this great jQuery plugin, it will be more quick and easy. (only works with jQuery lte 1.9)
This will add a border to all area with class bordered, change to your liking. area.bordered{ outline:1px solid red; } See http://www.w3schools.com/css/css_outline.asp for more details.
How to make round mapped image change on hover?
I have a round image which I managed to find how to map in a previous question. I now wonder how I can make this image change when i hover over it. It has a mapped area. I have a problem on that. HTML version without CSS where i believe that the " usemap="#imagechange" " is causing the problem: <img src="1.png" onmouseover="this.src='2.png'" onmouseout="this.src='1.png'" width="100" height="100" alt="usemap" border="0" usemap="#imagechange"/> <map name="imagechange"> <area shape="circle" coords="50,50,50" href="image.com" /> </map> It works only when I am inside the area (= 100x100 area MINUS the circle area). I also have a version with css which doesnt work at all. HTML version with CSS: div class="imagechange" > <img src='foundation/images/Twitter.png' title="Map Image" alt="usemap" border="0" usemap="#imagechange"/> <map name="imagechange"> <area shape="circle" coords="50,50,50" href="index.html" /> </map> CSS .imagechange { width: 100px; height:100px; display:block; overflow:hidden; border-radius:50px; -webkit-border-radius:50px; } .imagechange:hover { border-radius:0px; -webkit-border-radius:0px; }
Use this: <a href='http://www.google.com/'> <img src='1.png' onmouseover="this.src='2.png'" onmouseout="this.src='1.png'" style='border:0px; border-radius:999px; -webkit-border-radius:999px;'/> </a>
HTML5 Keyboard audio with old IE fallback. IE8 image issue
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>