【问题标题】:Disable the "a" attribute underline? [duplicate]禁用“a”属性下划线? [复制]
【发布时间】:2016-03-29 01:35:48
【问题描述】:

我想知道对于 href 的“a”属性如何禁用下划线。我觉得这很烦人,我想知道是否可以在我的 .css 中添加一些代码来更改它。谢谢。

【问题讨论】:

    标签: html css


    【解决方案1】:

    一个简单的谷歌搜索提供了这非常容易......

    a {
        text-decoration: none;
    }
    

    【讨论】:

    • 禁用,不启用!
    【解决方案2】:

    只需设置a {text-decoration:none}

    实际操作:

    a {
      text-decoration: none
    }
    <a href="#">No Underline</a>

    编辑 (我正在编辑这个给投反对票的人,因为这可能是唯一的原因)

    如果您有多个a,其中一些没有href 属性,那么您可以像这样定位href

    /*demo */
    
    div {
      border: dotted lightblue;
      margin: 10px;
      font-size:30px
    }
    a {
      display: block;
    }
    /*in action*/
    div:last-of-type a[href] {
      text-decoration: none
    }
    <div>
      <a>Without href doesn't make it a link</a>
      <a href="#">Link with Underline</a>
    </div>
    <div>
      <a>Without href doesn't make it a link</a>
      <a href="#">Link Without Underline</a>
    </div>

    【讨论】:

    • 想知道为什么它会被否决
    猜你喜欢
    • 2011-07-31
    • 2014-04-14
    • 2012-09-13
    • 2018-08-13
    • 1970-01-01
    • 2013-02-21
    • 2021-08-20
    • 2014-02-24
    • 1970-01-01
    相关资源
    最近更新 更多