首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何指定(覆盖)JQuery图标颜色

要指定或覆盖 jQuery 图标的颜色,您可以使用 CSS 样式。以下是一个简单的示例,展示了如何为 jQuery 图标的颜色添加自定义样式。

  1. 首先,在 HTML 文件中包含 jQuery 和 jQuery UI 库。
代码语言:html
复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>jQuery Icon Color</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
   <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
   <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
    <!-- Your HTML content here -->
</body>
</html>
  1. 接下来,在 CSS 文件中添加自定义样式。
代码语言:css
复制
.ui-icon {
    background-image: none !important;
}

.ui-icon-custom:before {
    content: '\f005';  /* 使用 Font Awesome 图标,例如:颜色为红色的星形图标 */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    color: red;
}
  1. 在 HTML 文件中应用自定义样式。
代码语言:html
复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>jQuery Icon Color</title>
    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
   <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
   <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
   <style>
        .ui-icon {
            background-image: none !important;
        }

        .ui-icon-custom:before {
            content: '\f005';
            font-family: "Font Awesome 5 Free";
            font-weight: 900;
            color: red;
        }
    </style>
</head>
<body>
    <!-- Your HTML content here -->
</body>
</html>
  1. 最后,在 HTML 文件中使用自定义样式的图标。
代码语言:html<button class="ui-button ui-widget ui-corner-all ui-button-icon-only">
复制
    <span class="ui-button-icon-primary ui-icon ui-icon-custom"></span>
    <span class="ui-button-text">Custom Icon</span>
</button>

通过以上步骤,您可以为 jQuery 图标自定义颜色。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

领券