0

我剪掉了一堆代码来解决我需要帮助的问题,我有一个图像,当我将鼠标悬停在它上面时它会更改图像,但是当我单击该图像时我如何添加它会让你说mywebsite.com ?? http://pastebin.com/h83yi3e3

代码:

<html>
  <head>
    <style>
       #buttonOne {width:140px;height:60px;background-image:url(buttonOne.png);}
       #buttonOne:hover {width:140px;height:60px;background-image:url(buttonOneH.png);}
       #buttonTwo {width:140px;height:60px;background-image:url(buttonTwo.png);}
       #buttonTwo:hover {width:140px;height:60px;background-image:url(buttonTwoH.png);}
       #buttonThree {width:140px;height:60px;background-image:url(buttonThree.png);}
       #buttonThree:hover {width:140px;height:60px;background-image:url(buttonThreeH.png);}
    </style>
  </head>
  <body>    
      <div id="buttonOne">
      </div>

      <div id="buttonTwo">
      </div>

      <div id="buttonThree">
      </div>    
  </body>
</html>
4

3 回答 3

3

将这些divs 改为a标签。这就是他们的目的。如果您想要一个可以单击以转到另一个 url 的元素,那么您需要一个<a>标签。

<a id="buttonOne" href="http://letssaymywebsite.com/"></a>
<a id="buttonTwo" href="http://letssaymywebsite.com/"></a>
<a id="buttonThree" href="http://letssaymywebsite.com/"></a>
于 2012-11-20T06:53:08.617 回答
0

使用锚标签你可以这样做 -

<a id="buttonOne" href="mywebsite.com"></a>
...

然后你可以用它a:hover来改变图像

在 css-

#buttonOne a:hover
{
background-image:url(buttonOneH.png);
}
...
于 2012-11-20T06:55:07.240 回答
0

好吧,我不确定你们在谈论什么,删除了 div,对我没有用,我所做的是在我添加到不可见的链接图像中的那些空 div 中。

<div id="buttonOne">
<a href="mywebsite.com" target="_blank"><img src="inbut.png">
</a>
</div>
于 2012-11-20T16:40:14.453 回答