代码之家  ›  专栏  ›  技术社区  ›  CodeMan

如何在IE中删除锚伪元素的css中的下划线

  •  2
  • CodeMan  · 技术社区  · 10 年前

    如何删除 text-decoration: underline 用于Internet Explorer中的CSS伪元素?

    这个 + 图标在其他浏览器(如Google Chrome)中没有下划线,但在Internet Explorer中 + 图标下划线。如何删除Internet Explorer的下划线?

    《守则》( https://jsfiddle.net/u5m067xq/4/ ):

    h3 a { 
      text-decoration:underline;
    }
    h3 a:before {
      display:inline-block;
      content: '+';
      margin:0;
      padding: 4px;
      text-decoration:none;
    }
     <h3><a href="#">link</a></h3>
    1 回复  |  直到 9 年前
        1
  •  1
  •   Vucko    10 年前

    此代码按您的预期工作。的默认样式 a 标记为 text-decoration: underline .你必须设置它 none .

    span {
      text-decoration: underline;
    }
    h3 a:before {
      display: inline-block;
      content: '+';
      margin: 0;
      padding: 4px;
      text-decoration: none;
    }
    a {
      text-decoration: none;
    }
    <h3><a href="#"><span>link</span></a></h3>