我正在尝试将div转换为链接。下面的代码在firefox中工作正常,但在IE中,鼠标指针对链接没有反应。有没有解决的办法?谢谢。

<html>
<head>
<style type="text/css">
.test{
    width:100%;
    height:100px;
    background:#666666;
}
</style>
</head>

<body>
<a href="http://www.google.com">
    <div class="test">
        kjlkjlkjkljl
    </div>
</a>

</body>
</html>

最佳答案

我认为IE在这种情况下实际上可以正确响应。
div是块级元素;因此,不应将其包含在内联元素(例如a)中。如果您使用span(代替div)在IE和Firefox中都可以使用?

如果要使其看起来像一个链接(就光标而言),那么您可能要使用:

a > div, /* please change your mark-up to the following */
a > span {cursor: hand; /* for earlier versions of IE */
          cursor: pointer; /* for, I think, IE 7+ and FF etc. */
}

关于html - 将Div转换为Link,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2134310/

10-12 00:16
查看更多