【发布时间】:2017-07-28 18:33:57
【问题描述】:
我正在查看 HTML 热点,并且对我在之前的 Stack Overflow Q&A 中找到的示例有疑问。
Previous Stack OverFlow Area Example
在“Gibberish”的第一个答案中,他提供了一个关于 JSFiddle 的工作示例。 JSFiddle Example from Gibberish
function hovIn() {
var areaID = $(this).attr('id');
//alert('['+areaID+']');
if (areaID == 'CUST_1') {
$('#myDiv').show();
}
}
function hovOut() {
$('#myDiv').hide();
}
$('map area').hover(hovIn, hovOut);
#num_cust1 {
padding: 10px;
background-color: yellow;
position: absolute;
top: 60px;
left: 180px;
}
#num_cust2 {
padding: 10px;
background-color: yellow;
position: absolute;
top: 60px;
left: 40px;
}
#num_cust3 {
padding: 10px;
background-color: yellow;
position: absolute;
top: 160px;
left: 180px;
}
#myDiv {
display: none;
width: 50%;
height: 50px;
padding: 10px;
background-color: skyblue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Instructions: Mouse over computer's monitor to see hidden DIV
<!--<img src="http://www.proprofs.com/quiz-school/upload/yuiupload/2014513384.jpg" width="400" height="400" />-->
<div id="imagemap">
<img src="http://img716.imageshack.us/img716/8287/3ylp.jpg" width="275" height="207" usemap="#Map" border="0" />
<map name="Map">
<area shape="poly" coords="105,26,107,126,257,140,256,27" href="#" id="CUST_1" name="CUST:1" />
<area shape="poly" coords="10,21,14,178,71,184,69,19" href="#" id="CUST_2" name="CUST:2" />
<area shape="poly" coords="113,145,94,172,241,192,251,164,250,164" href="#" id="CUST_3" name="CUST:3" />
</map>
<p>
<div id="myDiv">This DIV hidden unless hover over the computer's monitor</div>
</p>
</div>
<!-- Yellow DIV ID numbers overlaid on top of computer components -->
<div id="num_cust1">1</div>
<div id="num_cust2">2</div>
<div id="num_cust3">3</div>
我了解大多数答案是如何工作的)。谁能解释他们如何/为什么在没有任何代码(我可以看到)的情况下显示为蓝色??
Fiddle 输出的屏幕截图,显示蓝色点击区域:
【问题讨论】:
-
当您使用
<area>标签时,它会自动让您选择它并在其周围添加默认的蓝色边框。
标签: javascript jquery html css area