真正的初學者對鏈接中的粗略藝術品提出質疑和道歉,但我很努力地在沒有它的情況下表達清楚。此外,作爲一個新的海報,我只限於每個問題的兩個超鏈接,所以不要鏈接下面使用的代碼。單擊圖像顯示錶
我有一個圖像來放置觸發點。點擊觸發器後,理想情況下會出現表格。例如,如果我點擊屋頂,我想要一張桌子說屋頂是藍色的,或者門的那個是紅色的。
我一直在玩這些,但還沒有任何成功。
HTML圖像地圖
<!DOCTYPE html>
<html>
<body>
<p>Click on the sun or on one of the planets to watch it closer:</p>
<img src="https://www.w3schools.com/tags/planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
</body>
</html>
CSS左/右鍵屬性
<!DOCTYPE html>
<html>
<head>
<style>
div.relative {
position: relative;
width: 400px;
height: 200px;
border: 3px solid #8AC007;
}
div.absolute {
position: absolute;
right: 20px;
width: 200px;
height: 120px;
border: 3px solid #8AC007;
}
</style>
</head>
<body>
<div class="relative">This div element has position: relative;
<div class="absolute">This div element has position: absolute. It is placed 20 pixels to the left of the right edge of the containing positioned element (div with class="relative").</div>
</div>
</body>
</html>
JQuery的
$(function() {
$("#test").click(function(e) {
var offset = $(this).offset();
var relativeX = (e.pageX - offset.left);
var relativeY = (e.pageY - offset.top);
alert(relativeX+':'+relativeY);
$(".position").val("afaf");
});
});
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<div class="position">Hello</div><br/><br/>
<div >
<div>
<div>
<a id="test">
<img class="demo-box" src="http://www.degordian.com/static/img/shareImg/degordian.png" />
</a>
</div>
</div>
</div>
<br/><br/>Hello again<br/><br/>
<div >
<img class="demo-box" src="http://www.degordian.com/static/img/shareImg/degordian.png" />
</div>
類卡在哪裏開始,因此在正確的方向的任何指針將不勝感激。這就是圖像看起來的樣子,它應該如何呈現。
你可以發佈一個[jsfiddle](https://jsfiddle.net/)它變得更清晰一些ppl – utdev
Daftly,我沒有代碼了,但我會考慮重做它不久。 – jdiawn1411