简体   繁体   English

链接HTML CSS和图像

[英]link html css and an image

I would like to add actions to this image 我想对此图像添加操作 图片 So when the user hovers over red dot, some information appears, or when clicks (modal from bootstrap appears). 因此,当用户将鼠标悬停在红点上时,将显示一些信息,或者单击时(出现引导程序的模态)。 I am using bootstrap, and spreading divs over the image don't give normal result. 我正在使用引导程序,并且在图像上散布div不能得到正常结果。 I want it to be responsive. 我希望它能及时响应。 Any ideas? 有任何想法吗?

在html dom上应该有一个JavaScript的onhover方法。

 <div id="point1" onmouseover="doHover('point1', true);" onmouseout="doHover('point1', false);"></div> 

So, you have a problem with the divs? 那么,您对div有问题吗?

 function doHover(id, bool) { var obj = document.getElementById("hoverPoint"+id); if(bool) { obj.style.backgroundColor="green"; }else { obj.style.backgroundColor="blue"; } } 
 .hoverPoint { position:absolute; top: 0px; left: 0px; width:100px; height:100px; display:block; background-color: blue; opacity: .6; } #hoverPoint1 { top: 130px; left: 135px; } 
 <img src="http://i.stack.imgur.com/sUTxI.png" style="width:777px; height:292px" /> <div class="hoverPoint" id="hoverPoint1" onmouseover="doHover(1,true);" onmouseout="doHover(1,false);"></div> 

我通过在Photoshop中删除红点解决了问题,然后使用纯html将其添加(我用红点的背景图像制作了按钮),然后将这些点随机放置在路线图上

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM