使用display:block时链接的问题 [英] Problem with IE when using display:block for links

查看:182
本文介绍了使用display:block时链接的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的HTML:

<div id="links">
  <a href="">Link 1</a>
  <a href="">Link 2</a>
  <a href="">Link 3</a>
  <a href="">Link 4</a>
</div>

这些是CSS样式:

#links {
    position: absolute;
    border: 1px solid #000;
}

#links a {
    display: block;
}

#links a:hover {
    background-color: #CCC;
}

这会显示链接列表,问题是在IE中,只有通过直接点击文本链接点击一个链接,这是不是与其他浏览器的情况(在那里你可以点击任何地方,无论是文本链接还是其他任何地方,只要它在链接块),是有任何修复(与

This displays a list of links, the problem is that in IE, I can only click a link by directly clicking the text link, which is not the case with other browsers (where you can click anywhere whether the text link or anywhere else as long as it's in the link block), is there any fix for that (with only CSS, no javascript)?

请注意,我不想为链接或div指定宽度。

Please note that I don't want to specify a width for the links or the div.

推荐答案

将链接文本包含在span元素中。然后它将接受点击范围内的任何地方。

Enclose the link text in a span element. Then it will accept clicks anywhere within its bounds.

这篇关于使用display:block时链接的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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