代码之家  ›  专栏  ›  技术社区  ›  Bojan Kolano

删除链接部分的下划线

  •  2
  • Bojan Kolano  · 技术社区  · 8 年前

    enter image description here

    这是我正在使用的代码。

    a {
    
    
    font-size: 14px;
      text-decoration: none;
      color: $grey;
      font-weight: bold;
      text-decoration: underline;
      &:hover {
        cursor: pointer;
      }
    
      &:before {
        content: '\1F847';
        color: $green;
        padding-right: 8px;
        text-decoration: none;
      }
    
      &:after {
        text-decoration: none;
      }
    }
    

    我需要的箭头,是作为一个内容添加到没有下划线作为文字装饰,但文字需要保持它。如你所见,我试图补充 text-underline:none 之前和之后,但都没用。如果需要,我可以使用JS/Query,但仍然不知道如何做到这一点。

    2 回复  |  直到 8 年前
        1
  •  4
  •   user10058046 user10058046    8 年前

    :before inline-block

      &:before {
        content: '\1F847';
        color: $green;
        padding-right: 8px;
        text-decoration: none;
        display: inline-block;
      }
    
        2
  •  2
  •   gavgrif    8 年前

    你可以申请 text-decoration: none 到 a text-decoration: underline 的 a span . 注意,我不得不重新调整你的css一点,因为我们没有一个预处理器。

    a {
      font-size: 14px;
      text-decoration: none;
      color: grey;
      font-weight: bold;
      text-decoration: none;
      }
      
    a span {
      text-decoration: underline;
      }
      
     a:hover {
        cursor: pointer;
      }
    
     a:before {
        content: '\1F847';
        color: green;
        padding-right: 8px;
        text-decoration: none;
      }
        <a href="#"><span>2015 Highlights</span></a>