图像区域中没有变成可点击区域的图像区域

时间:2015-09-06 01:16:26

标签: html imagemap

我正在尝试创建如下的HTML图像映射(请在下面找到我的代码):

h1 {
  background-color: red;
}
 <h1> This is Frame A </h1>


<img src="http://image.slidesharecdn.com/thesolarsystem-100324192727-phpapp01/95/the-solar-system-2-728.jpg?cb=1269517813" width="500" height="300" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="circle" coords="450,208" href="https://www.nasa.gov/sites/default/files/706436main_20121114-304-193blend_m6-orig_full.jpg" alt="Sun">
  <area shape="circle" coords="305,124" href="http://vignette2.wikia.nocookie.net/heman/images/3/36/Earth.jpg/revision/latest?cb=20130912205625" alt="Earth">
  <area shape="circle" coords="652,122" href="https://upload.wikimedia.org/wikipedia/commons/8/85/Venus_globe.jpg" alt="Venus">
</map>

图像显示在网页上,但是,太阳,地球和金星没有变成可点击的东西,所以我可以将它指向各自的图像。请让我知道我做错了什么?我是否正确指定了坐标?

我使用以下Image Generator找出坐标:

1 个答案:

答案 0 :(得分:1)

这是因为coords需要三个项而不是2个:x,y,radius。所以你需要为半径添加值(这是一个例子):

&#13;
&#13;
h1 {
  background-color: red;
}
&#13;
 <h1> This is Frame A </h1>


<img src="http://image.slidesharecdn.com/thesolarsystem-100324192727-phpapp01/95/the-solar-system-2-728.jpg?cb=1269517813" width="500" height="300" alt="Planets" usemap="#planetmap">

<map name="planetmap">
  <area shape="circle" coords="330,118,60" href="https://www.nasa.gov/sites/default/files/706436main_20121114-304-193blend_m6-orig_full.jpg" alt="Sun">
  <area shape="circle" coords="205,70,30" href="http://vignette2.wikia.nocookie.net/heman/images/3/36/Earth.jpg/revision/latest?cb=20130912205625" alt="Earth">
  <area shape="circle" coords="452,82,35" href="https://upload.wikimedia.org/wikipedia/commons/8/85/Venus_globe.jpg" alt="Venus">
</map>
&#13;
&#13;
&#13;

注意:由于您将图片的宽度和高度定义为width="500" height="300",因此您需要更改x,y坐标以进行调整。这就是我在答案中改变它们的原因。