【发布时间】:2017-03-17 02:03:03
【问题描述】:
有点新手问题,谷歌没有太多发现,至少最近没有。
我有一个简单的水平工具栏图像映射。 我最终想要做的是在鼠标悬停在该区域上方时绘制一个 rgba 矩形。
但我不能让它在这里做很多事情。似乎区域元素的工作方式有点不同。请问我该如何用纯javascript做到这一点。没有 jquery。
<html>
<body>
<script>
function tellname(txt){
document.getElementById("info").innerHTML=txt;
}
</script>
<style>
.highlight:hover {
outline: 1px solid orange;
}
</style>
<img src="toolbar.png" usemap="#toolbar" />
<map name="#toolbar">
<area class="highlight" shape="rect" coords="0,0,25,25" onclick="tellname('Centre')"/>
<area class="highlight" shape="rect" coords="25,0,50,25" onclick="tellname('Reset Camera')" />
<area class="highlight" shape="rect" coords="50,0,75,25" onclick="tellname('Camera Preset')" />
<area class="highlight" shape="rect" coords="95,0,120,25" onclick="tellname('Stop Render')" />
<area class="highlight" shape="rect" coords="120,0,145,25" onclick="tellname('Restart Render')" />
<area class="highlight" shape="rect" coords="160,0,185,25" onclick="tellname('Pause Render')" />
<area class="highlight" shape="rect" coords="190,0,205,25" onclick="tellname('Start Render')" />
</map>
<div id='info'</div>
</body>
</html>
【问题讨论】:
-
区域没有样式。构建一个真正的工具栏。几十年来一直不推荐使用像这样的图像布局。
标签: javascript css imagemap