我有一个java脚本,当鼠标悬停在图像上时,它基本上会改变图像的zindex。虽然这个工作我不得不重做一些维度和CSS中的定位。现在没有为图像运行脚本。要查看示例,请转到http://officialacescottie.co.uk并检查Home是否正常工作以及其他任何工作正常。
JS
<script>
A=""
function mouseover1() {
document.getElementById(A).style.zIndex="1"
}
function mouseoff1() {
document.getElementById(A).style.zIndex="100"
}
</script>
CSS
#HButton { background-image:url(../DefaultPage/Buttons/Home.gif); background-color:#000; height:14.8%; width:100%; color:#FFF; background-size:100%; position:absolute; z-index:90; left:0px; background-repeat:no-repeat;}
#HButton2 { background-image: url(../DefaultPage/Buttons/HomeP.gif); background-color:#000; height:14.8%; width:100%; color:#FFF; background-size:100%; position:absolute; z-index:89; top:0px; left:0px; background-repeat:no-repeat;}
那是破解的CSS代码
这个有效:
CSS
#HButton { background-image:url(../DefaultPage/Buttons/Home.gif); background-color:#000; float:left; height:60px; width:350px; color:#FFF; background-size:100%; position:relative; z-index:90;}
#HButton2 { background-image: url(../DefaultPage/Buttons/HomeP.gif); background-color:#000; float:left; height:60px; width:350px; color:#FFF; background-size:100%; position:relative; z-index:10; top:-60px;}
两个代码都使用相同的div标签
HTML
<div id="HButton" onmouseover="A='HButton'; mouseover1()" onmouseout="A='HButton'; mouseoff1()">
</div>
<div id="HButton2" onmouseover="A='HButton'; mouseover1()" onmouseout="A='HButton'; mouseoff1()">
</div>
答案 0 :(得分:0)
函数鼠标悬停1(A)
答案 1 :(得分:0)
我能够发现两个不同之处:
1) You have google ads on home but not AceWorks (dont think this is causing the issue)
2) You closed the script tag on AceWorks but missed it on Home
请调整#2。
答案 2 :(得分:0)
检查您的控制台日志,表示未定义功能。
另一种方法可能是这样的:
<强>的Javascript 强>
function mouseIn(y){
y.style.zIndex = "1";
}
function mouseOut(y){
y.style.zIndex = "100";
}
HTML
<div id="HButton" onmouseover="mouseIn(this)" onmouseout="mouseOut(this)"></div>