2015-09-06 73 views
1

我试图创建一个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

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

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="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>

注:因为你定义的图像的宽度和高度width="500" height="300",你将需要改变x,y坐标来调整。这就是为什么我在回答中改变了他们。

+0

感谢您的回答。是的,我看到关于添加半径并想知道你是如何得出不同的半径值的?他们是精确的还是最好的猜测? – John

+0

@John他们只是我的最好的猜测通过试验和错误:) –

+0

我明白了。所以没有特别的方法来精确地找到这些价值。 – John