IE:只有部分锚点是可点击的 [英] IE: Only part of an anchor is clickable

查看:100
本文介绍了IE:只有部分锚点是可点击的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个具有特定高度和宽度的锚点。

I want to have an anchor with a specific height and width.

没有文字,因为它的意思是放在某个区域的前面

There is no text on it since it's meant to be put in front of a certain area of the page.

以下是代码:

<a href="/" style="width:370px;height:80px;display:block;position:absolute;"></a>

在IE6和IE7以外的任何东西都可以正常工作。如果我添加边框,我可以看到锚点具有正确的大小,但如果我尝试点击它,只有顶部可点击

It's working fine in everything but IE6 and IE7. If I add a border, I can see that the anchor has the correct size, but if I try to click it, only the top part will be clickable.

我不知道为什么它这样做。我尝试添加一个onclick,即使有一个警报,同样的事情,它是不可能点击锚的底部。

I don't know why it's doing this. I tried adding a onclick even with an alert, and the same thing, it's impossible to click on the bottom part of the anchor.

这真的很奇怪,之前的任何人?任何事情都会有帮助。

It's really weird, did this happen to anyone before? Anything will help.

推荐答案

在以前的IE版本中,不可能在块级元素上注册onclick事件。相反,IE会将onclick应用到块中的文本或内联元素。

In previous versions of IE, its not possible to register the onclick event on block level elements themselves. Instead, IE applies the onclick to the text or inline elements inside the block.

我发现将透明图像在锚点内,与完整锚点大小相同,将注册onclick。

I've found that putting a transparent image inside the anchor that is the same size as the full anchor will register the onclick.

<a href="/" style="width:370px;height:80px;display:block;position:absolute;">
    <img src="Transparent.gif" style="width: 370px; height: 80px"/>
</a>

这篇关于IE:只有部分锚点是可点击的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆