【问题标题】:Disable underline of inside element of underlined anchor tag [duplicate]禁用带下划线的锚标记的内部元素的下划线[重复]
【发布时间】:2015-01-14 05:29:19
【问题描述】:

我们可以禁用带下划线的锚标记的内部跨度元素的下划线吗?如果可以,请告诉我怎么做?

 <a>hello<span>praveen</span</a>

 <style type="text/css>
     a{
        text-decoration:underline;
     }
     a span{
        text-decoration:none;
     }
 </style>

【问题讨论】:

标签: html css


【解决方案1】:

试试这个。

为 span 样式添加 display: inline-block;

a {
    text-decoration:underline;
}

a span {
    text-decoration:none;
    display: inline-block;
}

http://jsfiddle.net/4oqyx6Le/2/

【讨论】:

    【解决方案2】:

    一个>跨度{ 文字装饰:无: }

    【讨论】:

    • 寻找父 a 的子元素 span 并且不会为该元素分配任何装饰。
    • OP 想要 text-decoration:none 仅用于带下划线的锚点内的跨度
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-14
    • 1970-01-01
    • 2011-10-19
    • 1970-01-01
    • 2018-08-13
    • 1970-01-01
    相关资源
    最近更新 更多