【问题标题】:Multiple CSS on hover effects on one image一个图像上的悬停效果上的多个 CSS
【发布时间】:2016-04-10 13:43:51
【问题描述】:

我有一个包含多个坐标的图像地图,我希望每个部分都有悬停效果。效果应该只出现在当前悬停的部分,其他部分应该保持正常

图片地图:

 <!-- Calculations based on an original image (width,height)=(3106,2071) -->
<img src="http://imagemap-generator.dariodomi.de/uploads/160410_151558_5a93c70d827455Ae.jpg" alt="" usemap="#Map" style="height: 715px; width: 1075px;">
<map name="Map" id="Map">
    <area alt="" title="" href="http://www.google.com" shape="poly" coords="382,37,522,37,589,157,521,276,382,278,313,158">
    <area alt="" title="" href="http://www.facebook.com" shape="poly" coords="171,158,309,160,379,279,311,399,170,398,101,279">
    <area alt="" title="" href="http://www.example.com" shape="poly" coords="315,400,380,281,517,283,590,401,520,520,384,521">
    <area alt="" title="" href="http://www.mail.google.com" shape="poly" coords="524,521,593,405,729,404,801,522,732,644,592,641">
    <area alt="" title="" href="http://www.random.com" shape="poly" coords="737,397,801,281,943,281,1013,400,945,521,803,520">
    <area alt="" title="" href="http://www.ebay.com" shape="poly" coords="525,277,595,159,731,158,800,277,733,396,592,398">
    <area alt="" title="" href="http://www.instagram.com" shape="poly" coords="735,157,803,37,941,37,1011,156,943,276,804,276">
</map>

悬停效果:

 img.grayscale {
    filter: url("data:image/svg+xml;utf8,&lt;svg xmlns=\'http://www.w3.org/2000/svg\'&gt;&lt;filter id=\'grayscale\'&gt;&lt;feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/&gt;&lt;/filter&gt;&lt;/svg&gt;#grayscale"); /* Firefox 10+, Firefox on Android */
    filter: gray; /* IE6-9 */
    -webkit-filter: grayscale(100%); /* Chrome 19+, Safari 6+, Safari 6+ iOS */
}

【问题讨论】:

标签: css imagemap


【解决方案1】:

我不认为你可以用地图区域做到这一点,但你可以用 svg 做到这一点:

<svg  id="Map" style="height: 715px; width: 1075px;">
   <a xlink:href="http://www.google.com"><polygon points="382,37,522,37,589,157,521,276,382,278,313,158"/></a>
   <a xlink:href="http://www.facebook.com"><polygon points="171,158,309,160,379,279,311,399,170,398,101,279"/></a>
   <a xlink:href="http://www.example.com"><polygon points="315,400,380,281,517,283,590,401,520,520,384,521"/></a>
   <a xlink:href="http://www.mail.google.com"><polygon points="524,521,593,405,729,404,801,522,732,644,592,641"/></a>
   <a xlink:href="http://www.random.com"><polygon points="737,397,801,281,943,281,1013,400,945,521,803,520"/></a>
   <a xlink:href="http://www.ebay.com"><polygon points="525,277,595,159,731,158,800,277,733,396,592,398"/></a>
   <a xlink:href="http://www.instagram.com"><polygon points="735,157,803,37,941,37,1011,156,943,276,804,276"/></a>
</svg> 

和css:

svg#Map {background:url(http://imagemap-generator.dariodomi.de/uploads/160410_151558_5a93c70d827455Ae.jpg); 
background-size:cover;
}

#Map polygon {fill:rgba(0,0,0,0)}
#Map polygon:hover {
 fill:rgba(0,0,0,0.3)
}

看到这个小提琴:https://jsfiddle.net/grassog/akgs3zyt/

【讨论】:

  • 您不会碰巧知道如何在点击时显示灯箱吧? imagemap-generator.dariodomi.de/uploads/…" alt="" usemap="#Map" style="height: 715px;宽度:1075px;"> google.com" shape="poly" coords="382,37,522,37,589,157,521,276,382,278,313,158" class="et_pb_lightbox_image">
  • 我会说 onclick 事件(类似于 &lt;polygon points="735,157,803,37,941,37,1011,156,943,276,804,276" onclick="lightbox()"/&gt; )但也许这值得提出一个新问题?
猜你喜欢
  • 2021-01-10
  • 1970-01-01
  • 2018-09-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-21
  • 2010-11-30
相关资源
最近更新 更多