html - a 标签内的不同悬停行为。 IE 8+ 中的问题

标签 html css internet-explorer hover text-decorations

我在使用 Internet Explorer 8+ 时遇到以下问题。它适用于所有其他浏览器。

我不希望在 a 标签内的 i 标签上有下划线悬停效果。 IE 8+ 忽略 i-tag 上的 hover 伪类。 这是 HTML 代码:

<a href="#"><i class="icon-print"></i>Print</a>

这是关联的 CSS 代码:

a:hover {text-decoration: underline;}
a i:hover {text-decoration: none;}

最佳答案

将“print”包裹在span

<a href="#"><i class="icon-print"></i><span>Print</span></a>

在CSS中

a {text-decoration:none;}
a:hover {text-decoration:none;}
a:hover > span { text-decoration:underline;}

JsFiddle

关于html - a 标签内的不同悬停行为。 IE 8+ 中的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18469341/

相关文章:

javascript - 在 jQuery 中每次滚动一个 div

javascript - 将现有元素注入(inject) React

css - Div重叠问题

jquery - IE8图像缓存或错误?

internet-explorer - IE9酸3测试?

javascript - 从 sprite 图像中提取图像时,Canvas 无法正确绘制边缘

javascript - 基于单选按钮显示/隐藏表单字段

html - flex 元素 - 填充剩余的容器高度

css - JSF 2 panelGrid 列格式 - 统一对齐

javascript - Internet Explorer Javascript 性能问题