Image Map元素无法关联Image元素问题求助
解决Image Map与Image无法关联的问题
我来帮你搞定这个问题!仔细看了你的代码,核心问题出在坐标不匹配上——你的图片实际显示尺寸是360px × 425px,但<area>标签里的coords数值(比如792,262)远远超出了这个范围,导致所有热点区域都落在了可见图片之外,自然没法触发点击,看起来就像是和图片没关联上。
修复步骤:
- 首先确认图片的实际渲染尺寸:你给图片设置了
width: 360px; height: 425px;,所有热点坐标都要基于这个尺寸来计算 - 重新生成适配的坐标:可以用图片地图生成工具(根据显示尺寸上传图片后拖拽生成热点,自动获取正确的coords),或者手动测量热点在图片上的相对位置
- 确保
usemap属性和<map>的name完全匹配:你的代码里usemap="#image-map"和<map name="image-map">是匹配的,这部分没问题
修正后的代码示例:
<tbody> <tr> <td colspan="1" rowspan="4" style="width: 209px;" valign="middle" align="center"> <img src="https://i.imgur.com/sEwFehp.png" style="width: 360px; height: 425px; margin-left: 20px; margin-right: 20px;" usemap="#image-map"> <map name="image-map"> <!-- 以下是适配360×425尺寸的示例坐标,你需要根据实际热点位置调整 --> <area target="_blank" alt="veneboer" title="veneboer" href="http://www.veneboercampers.nl/" coords="165,55,235,95" shape="rect"> <area target="_blank" alt="dejong" title="dejong" href="http://www.dejonghattem.nl/" coords="240,150,310,185" shape="rect"> <area target="_blank" alt="acb" title="acb" href="https://www.acb-caravans.nl/" coords="175,160,240,215" shape="rect"> <area target="_blank" alt="caravanextra" title="caravanextra" href="https://www.caravanextra.nl/" coords="175,310,250,345" shape="rect"> <area target="_blank" alt="mobiledrome" title="mobiledrome" href="http://www.mobiledrome.nl/" coords="45,285,115,335" shape="rect"> </map> </td> </tr> </tbody>
注意:上面的coords是示例值,你需要根据图片上各个品牌logo的实际位置,重新生成对应360×425尺寸的坐标,这样热点就能准确对应到图片上的区域,正常触发跳转了。
内容的提问来源于stack exchange,提问作者MdeGraaff
相关产品推荐
相关产品推荐

