简体   繁体   English

我的翻转图像无法正常工作

[英]My rollover image is not working correctly

I have this rollover image for my final project in class and I need to use Dreamweaver's features to help accomplish this task. 我在课堂上的最后一个项目有这张翻转图像,我需要使用Dreamweaver的功能来帮助完成此任务。

So after doing it, my rollover image doesn't work. 因此,执行此操作后,我的过渡图像不起作用。

Here is what it looks like without mouseover: 这是没有鼠标悬停时的外观:

http://i.stack.imgur.com/CdEOL.jpg

and here is what it looks like with mouseover (or suppose to anyways): 这是鼠标悬停时的样子(或无论如何都应该如此):

http://i.stack.imgur.com/6gZvF.jpg

I feel dreamweaver probably put some unnecessary coding in there which is why it is not quite working, so the coding that it did for me is: 我觉得Dreamweaver可能在其中放置了一些不必要的编码,这就是为什么它不太起作用的原因,所以它为我做的编码是:

<p>
<a href="index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('1st-Link','','images/1st-link-roll.jpg',1)"><img id="firstlink" src="images/1st-link.jpg" alt="TAP" id="1st-Link" /></a><a href="whatis.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('2nd-Link','','images/2nd-link-roll.jpg',1)"><img id="rollover" src="images/2nd-link.jpg" alt="Who is TAP" id="2nd-Link" /></a><a href="why.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('3rd-Link','','images/3rd-link-roll.jpg',1)"><img id="rollover" src="images/3rd-link.jpg" alt="Why we do it" id="3rd-Link" /></a><a href="resources.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('4th-Link','','images/4th-link-roll.jpg',1)"><img id="rollover" src="images/4th-link.jpg" alt="Resources" id="4th-Link" /></a>
</p>

and the JavaScript it put in is: 它放入的JavaScript是:

<script type="text/javascript">
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>

I don't know if you need it or not, but my CSS is: 我不知道您是否需要它,但是我的CSS是:

#rollover
{
    display:block;
    width:120px;
    border:1px solid #000;
    float:left;
    margin-top:30px;
    border:1px solid #000
}

#firstlink
{
    display:block;
    width:120px;
    border:1px solid #000;
    float:left;
    margin-top:30px;
    margin-left:265px;
}

You don't need to use images or JavaScript at all. 您根本不需要使用图像或JavaScript。 You could simply use divs and a hover effect to change the colour like so: 您可以简单地使用div和hover效果来更改颜色,如下所示:

HTML : HTML

<div class="rollover">TAP</div>

CSS : CSS

.rollover
{
    display:block;
    width:120px;
    text-align:center;
    background-color:yellow;    
}

.rollover:hover
{
    background-color:red;    
}

If you do need to use an image, then you can do a similar thing with a hover effect that alters the background image of the div. 如果确实需要使用图像,则可以执行类似的操作,具有悬停效果,可改变div的背景图像。

See this DEMO . 看到这个演示

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

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