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

修改css以便不改变文本颜色

css
  •  1
  • ixodid  · 技术社区  · 4 年前

    我使用的HTML和css从共享按钮.io网站上的社交媒体按钮。

    神经按钮正常: enter image description here

    enter image description here

    根据需要更改填充颜色。但它也会改变文本的颜色。我希望文本保持白色。我该怎么做?

    .resp-sharing-button__link,
    .resp-sharing-button__icon {
      display: inline-block
    }
    
    .resp-sharing-button__link {
      text-decoration: none;
      color: #fff;
      margin: 0.5em
    }
    
    .resp-sharing-button {
      border-radius: 5px;
      transition: 25ms ease-out;
      padding: 0.5em 0.75em;
      font-family: Helvetica Neue,Helvetica,Arial,sans-serif
    }
    
    .resp-sharing-button__icon svg {
      width: 1em;
      height: 1em;
      margin-right: 0.4em;
      vertical-align: top
    }
    
    .resp-sharing-button--small svg {
      margin: 0;
      vertical-align: middle
    }
    
    /* Non solid icons get a stroke */
    .resp-sharing-button__icon {
      stroke: #fff;
      fill: none
    }
    
    /* Solid icons get a fill */
    .resp-sharing-button__icon--solid,
    .resp-sharing-button__icon--solidcircle {
      fill: #fff;
      stroke: none
    }
    
    .resp-sharing-button--twitter {
      background-color: #55acee
    }
    
    .resp-sharing-button--twitter:hover {
      background-color: #525250
    }
    
    .resp-sharing-button--facebook {
      background-color: #3b5998
    }
    
    .resp-sharing-button--facebook:hover {
      background-color: #525250
    }
    
    .resp-sharing-button--email {
      background-color: #777
    }
    
    .resp-sharing-button--email:hover {
      background-color: #525250
    }
    
    .resp-sharing-button--facebook {
      background-color: #3b5998;
      border-color: #3b5998;
    }
    
    .resp-sharing-button--facebook:hover,
    .resp-sharing-button--facebook:active {
      background-color: #525250;
      border-color: #525250;
    }
    
    .resp-sharing-button--twitter {
      background-color: #55acee;
      border-color: #55acee;
    }
    
    .resp-sharing-button--twitter:hover,
    .resp-sharing-button--twitter:active {
      background-color: #525250;
      border-color: #525250;
    }
    
    .resp-sharing-button--email {
      background-color: #777777;
      border-color: #777777;
    }
    
    .resp-sharing-button--email:hover,
    .resp-sharing-button--email:active {
      background-color: #525250;
      border-color: #525250;
    }
    

    HTML格式

    !-- Sharingbutton Facebook -->
    <a class="resp-sharing-button__link" href="https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Fexample.com" target="_blank" rel="noopener" aria-label="Facebook">
      <div class="resp-sharing-button resp-sharing-button--facebook resp-sharing-button--medium"><div aria-hidden="true" class="resp-sharing-button__icon resp-sharing-button__icon--solid">
        <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.77 7.46H14.5v-1.9c0-.9.6-1.1 1-1.1h3V.5h-4.33C10.24.5 9.5 3.44 9.5 5.32v2.15h-3v4h3v12h5v-12h3.85l.42-4z"/></svg></div>Facebook</div>
    </a>
    
    2 回复  |  直到 4 年前
        1
  •  2
  •   leech    4 年前

    你有没有试着添加 color: #fff; ? 这样地:

    .resp-sharing-button--facebook:hover,
    .resp-sharing-button--facebook:active {
      color: #fff;
      background-color: #525250;
      border-color: #525250;
    }
    
        2
  •  0
  •   A A    4 年前

    .resp-sharing-button--facebook:hover {
     background-color: #525250
     }
    

    你可以说 颜色:#fff或白色; 但是如果你特别针对facebook的文本,我想只要在文本周围加一个div就可以了

    你给它一个类,然后

    color: #fff;