如果我将图像分配给一个确定的宽度和高度,我有一个可以正常工作的热点图像。如果我使用width = 100%来使图像可缩放,那么当我的热点“左”/“宽”定位保持准确时,“顶部”/“高度”位置在整个位置移动。我知道我需要通过基于当前屏幕宽度的度量来设置我的顶部/高度位置,我只是没有如何编码的知识/语言。在可缩放的图像上放置热点
这是在图像处于原始尺寸(宽度1580,高度1050)时起作用的编码,所以如果我可以将我的顶部编码为顶部= 93%*(1050/1580)* new_screen_width但是!
我该怎么做?
这里是我的代码:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample Photo</title>
<style media="screen" type="text/css">
.hotspotted {
position: relative;
}
.hotspot {
display: block;
position: absolute;
}
#hotspot1 {
height: 8%;
left: 87%;
top: 85%;
width: 13%;
}
#hotspot2 {
height: 7%;
left: 92%;
top: 93%;
width: 4%;
}
#hotspot3 {
height: 7%;
left: 96%;
top: 93%;
width: 4%;
}
</style>
</head>
<body>
<div class="hot spotted">
<img src="images/homepage D.jpg" width="100%" />
<a href="DMD A.html" id="hotspot1" class="hotspot"></a>
<a href="DMD C.html" id="hotspot2" class="hotspot"></a>
<a href="index.html" id="hotspot3" class="hotspot"></a>
</div>
</body>
</html>
看起来像有在CSS中的错误 - 不.hotspotted,但.hot.spotted。 –