【问题标题】:WooCommerce Change Link color only for specific linkWooCommerce 仅针对特定链接更改链接颜色
【发布时间】:2020-11-07 06:03:32
【问题描述】:

我有这段代码可以插入链接并更改它们的颜色。我的问题是当我使用此代码时,页面上的所有链接都会将其颜色更改为此设置。但是我只想要这个链接的这些颜色,其他链接应该保持它们的颜色。

谁能帮帮我?

<!DOCTYPE html>
<html>
  <head>
    <style>
      /* unvisited link */
      a:link {
      color: #9c1006;
      }
      /* mouse over link */
      a:hover {
      color: #000000;
      }
      </style>
  </head>
  <body>
    <a href="link">link text</a></p> 

【问题讨论】:

    标签: html css wordpress woocommerce css-selectors


    【解决方案1】:

    您需要在 html 标签中添加一个“类”属性,例如:

    <a href="link" class="custom-link">link text</a></p> 
    

    那么您的 CSS 相关规则将改为:

    /* unvisited link */
    a.custom-link:link {
        color: #9c1006;
    }
    /* mouse over link */
    a.custom-link:hover {
        color: #000000;
    }
    

    【讨论】:

      猜你喜欢
      • 2018-06-27
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 2016-04-12
      • 1970-01-01
      • 1970-01-01
      • 2012-07-29
      • 1970-01-01
      相关资源
      最近更新 更多