我有图像,当鼠标悬停在上面时我想要一个 div,但我不希望它在鼠标移出时出现。我写了代码,它可以工作,但它在闪烁。 这是代码:
<div id="div" style="opacity:0.6; background-color:#2c3e50; width:136px; height:163px; z-index:199; position:absolute; vertical-align:top; font-size:120px; text-align:center; color:White; display:none;">1</div>
<img alt="ברק לוי" src="" style="background-color:red; height:163px; width:136px" onmouseover="picture(true)" onmouseout="picture(false)"/>
function picture(bool) {
if (bool) {
document.getElementById("div").style.display = "block";
}
else if (bool==false) {
document.getElementById("div").style.display = "none";
}
}
jsBin 我该如何解决?
最佳答案
只需将 onmouseover="picture(true)"onmouseout="picture(false)
添加到您的 div div。
关于javascript - Div 闪烁 onmouseover,onmouseout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23059574/