Javascript 鼠标悬停在阵列上的图像大小应更改
我已经实现了Java脚本游戏。我的游戏是桌上游戏。在存储的图像数组中。当移到图像上时,图像大小应该改变。从大图像到小图像。 我添加了下面的代码,请建议我合适的答案Javascript 鼠标悬停在阵列上的图像大小应更改,javascript,html,performance,Javascript,Html,Performance,我已经实现了Java脚本游戏。我的游戏是桌上游戏。在存储的图像数组中。当移到图像上时,图像大小应该改变。从大图像到小图像。 我添加了下面的代码,请建议我合适的答案 <script language="JavaScript"> document.open("text/plain"); document.writeln("<table border=3 cellpadding=0 bordercolor=silver width=10
<script language="JavaScript">
document.open("text/plain");
document.writeln("<table border=3 cellpadding=0 bordercolor=silver width=100% height=450px cellspacing=1 style=\"background-color:#e7e7e7; z-index:5; \" class=\"col-lg-12 col-md-12 col-sm-12\">");
for (j=0; j<Size; j++)
{ document.writeln("<tr width=50px height=0px align=center >");
for (i=0; i<Size; i++)
document.writeln("<td class=\"candy\"><IMG src=\"images\ball0.gif\" class=\"img-responsive\" border=0 onMouseDown=\"Clicked("+i+","+j+")\"></td>");
document.writeln("</tr>");
}
document.writeln("</table>");
document.close();
</script>
文件。打开(“文本/普通”);
文件。书面形式(“”);
对于(j=0;j您可以尝试以下方法:
或者使用普通css:
无论你想要哪个图像有悬停效果,给它一个类:“img zoom”
您可以在.hover函数上调整图像缩放(宽度和高度)。将此CSS样式添加到HTML中:
.img-responsive:hover {
zoom: 50;
}
演示:在一个类似于您的表格中,当您将鼠标悬停在表格单元格(td
)上时,最好缩小图像(img
)
当您将鼠标悬停在图像上时,如果调整图像大小或移动图像,则当您将鼠标悬停在边缘上时,浏览器会出现一些问题,而该边缘在鼠标悬停时会消失,从而导致图像闪烁
请参见此处的JSFIDLE示例:Didya是指当鼠标悬停在图像上时必须放大图像吗?(是否选择了它?)是的,正确,但是。缩放大小要小我没有加载您的图像。我使用不同的占位符设置了它-
.img-zoom:hover {
zoom: 0.5;
}
.img-responsive:hover {
zoom: 50;
}
td:hover img { zoom: 0.5; }