绝对定位锚标记(没有文本)在IE中不可点击 [英] absolute positioned anchor tag (with no text) not clickable in IE

查看:73
本文介绍了绝对定位锚标记(没有文本)在IE中不可点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个锚点位于图片顶部,这些链接可以在其他浏览器(Chrome,FF,Safari)中点击,但不能在IE中测试(目前为8& 9)

$ b $奇怪的是,如果我给链接a background-color 他们是可点击的,但是如果 background-color 设置为透明这是我想要的),他们不再可点击,我也试过设置 zoom:1 但没有运气。我想在IE中的 hasLayout 位已经消失了IE 8/9,所以猜测缩放



任何想法,使这些链接显示在IE 8/9与透明的bg?



这是我一直在使用的小提琴: jsFiddle示例



我有以下HTML布局:

 < div id =content> 
< img src =http://placehold.it/724x300width =724height =300alt =woot/>

< div id =countdown>< / div>

< a id =link1href =http://www.stackoverflow.comtitle =link1>< / a>
< a id =link2href =http://www.stackoverflow.comtitle =link2>< / a>
< / div>

和CSS:

  body {text-align:center;} 
#content {position:relative; width:724px; height:300px; margin:0 auto;}

#countdown {position:absolute; width:650px; height:110px; top:100px; left:30px; background-color:blue;}

#link1 {position:absolute; width:520px; height:35px; bottom:20px; left:0;}
#link2 {position:absolute; width:200px; height:35px; bottom:20px; right:0;}


解决方案

之前,它一直懊恼了我的地狱。我不知道为什么会发生,但我总是创建一个1px x 1px透明PNG(或GIF),并在后台声明中使用如下:

  a {background:url(/ path / to / image.png)0 0 repeat; } 

希望这有帮助。



- 不要指定任何实际的背景颜色。只要使用上面的例子,它应该工作。



除此之外,尝试并设置您的锚标签显示为块,也许还插入一个不间断的空间(因为它们现在是空的,并且可能是IE的跳闸):

  a {display:block; background:url(/ path / to / image.png)0 0 repeat; } 

< a href =#>& nbsp;< / a>


I have two anchors positioned absolute on top of an image, the links are clickable in other browsers (Chrome, FF, Safari) but not in IE (tested in 8 & 9 so far)

The strange thing is if I give the links a background-color they are clickable, however if the background-color is set to transparent (which is what I want) they are no longer clickable, I've also tried setting zoom:1 but no luck. I guess the hasLayout bit in IE went away with IE 8/9 so guessing zoom doesn't matter now for this kind of issue.

Any ideas to make these links show up in IE 8/9 with a transparent bg?

Here's the fiddle I've been working with: jsFiddle example

I have the following HTML layout:

<div id="content">
    <img src="http://placehold.it/724x300" width="724" height="300" alt="woot" />

    <div id="countdown"></div>

    <a id="link1" href="http://www.stackoverflow.com" title="link1"></a>
    <a id="link2" href="http://www.stackoverflow.com" title="link2"></a>
</div>

and CSS:

body {text-align:center;}
#content {position:relative; width:724px; height:300px; margin:0 auto;}

#countdown {position:absolute; width:650px; height:110px; top:100px; left:30px; background-color:blue;}

#link1 {position:absolute; width:520px; height:35px; bottom:20px; left:0;}
#link2 {position:absolute; width:200px; height:35px; bottom:20px; right:0;}

解决方案

I have had this exact problem before and it has always annoyed the hell out of me. I'm never sure why it happens, but I always create a 1px by 1px transparent PNG (or GIF) and use that in your background declaration like so:

a { background: url("/path/to/image.png") 0 0 repeat; }

Hope this helps.

PS - Don't specify any actual background colour with this. Just use the example above and it should work.

In addition to this, try and set your anchor tags to display as block and perhaps also insert a non-breaking space in them (since they are empty at the moment and that might be tripping IE up):

a { display: block; background: url("/path/to/image.png") 0 0 repeat; }

<a href="#">&nbsp;</a>

这篇关于绝对定位锚标记(没有文本)在IE中不可点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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