css - 仅从 anchor 元素子元素中删除下划线

标签 css

a 标签包含子元素时,比如 i 标签,它仍然在悬停时对其应用下划线,我想知道如何删除下划线当有人将鼠标悬停在 a 标签上时,仅来自 i 标签。

我正在使用的 CSS:

a{
    display:block;
    text-decoration:none;
}
a i{
  color:#888;
  margin-left:5px;
}
a:hover{
    text-decoration:underline;
}
a:hover i{
    text-decoration:none !important;
}

这里用fiddle来解释一下: http://jsfiddle.net/kkz66x2q/

我只是希望当您将鼠标悬停在链接上时,下划线只在 i 元素上消失。

最佳答案

尝试遵循 css,

a:hover i{
    display: inline-block; <-- this is the trick
    text-decoration:none !important;
}

Demo

关于css - 仅从 anchor 元素子元素中删除下划线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25762427/

相关文章:

css - 我可以在本身为 100% 高度的 DIV 中设置 100% 高度吗?

jquery - 在 facebook iframe 中添加自定义样式表

html - 我的 div 容器和这个 div 内的 html 表之间有一个很大的空白空间

javascript - JQuery - 单击时将背景图像替换为另一个背景图像

css - 如何防止 Less 尝试编译 CSS calc() 属性?

javascript - Grunt 不要连接 css 和 jquery 文件

css - 基础 6 中自定义尺寸的 xy 网格排水沟

javascript - 对动态图像内容使用媒体查询

javascript - Bootmetro 菜单模板

html - 将一个 div 置于另外两个 div 之上