更改背景颜色HTML区域坐标

时间:2015-01-21 21:52:51

标签: html css imagemap

我有一个中国内阁的形象。

使用图像地图我可以绘制点并制作hrefs:

<area id="vasetop" alt="" title="Vase on Top" href="#" onClick="reply_click(this)" shape="rect" coords="276,27,379,96" style="outline:none;" target="_self"  />

我拥有包含所有项目名称的数据库,如果可用,则每个项目的值为0,如果不可用,则为1。

我想做的是如果说:

vasetop的值为1我想以某种方式删除它。

我的代码看起来像

$result = mysqli_query($con,"SELECT * FROM stuff where status='1'");
    while($row = mysqli_fetch_array($result)) {
        if ($row['items'] == "vasetop"){
            <area show black box at these coords="276,27,379,96" />
        }
        else {
            <area id="vasetop" alt="" title="Vase on Top" href="#" onClick="reply_click(this)" shape="rect" coords="276,27,379,96" style="outline:none;" target="_self"  />
        }
}

接近那个。

无论如何都可以在html中设置coords的背景颜色吗?

我真正想要的是一些可以执行以下操作的代码。

<div coords="276,27,379,96" style="background-color: #FFFFFF;">

1 个答案:

答案 0 :(得分:1)

您可以在地图上放置绝对定位的div,例如:

<div style="position:absolute; 
top:27px; 
left:276px; 
width:103px; /*379-276*/
height:69px; /* 96-27 */
background:#fff;"></div>

但是只用矩形很容易,用圆形和多边形做这样的事情要麻烦得多......