如何将自定义图标添加到标准 jQuery UI 主题? [英] How do I add a custom icon to a standard jQuery UI theme?

查看:34
本文介绍了如何将自定义图标添加到标准 jQuery UI 主题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用标准图标集中可用的图标之一很容易:

It is easy to use one of the icons available from the standard icon set:

$("#myButton").button({icons: {primary: "ui-icon-locked"}});

但是如果我想添加一个不属于框架图标集的我自己的图标怎么办?

But what if I want to add one of my own icons that is not part of the framework icon set?

我认为这就像为它提供带有背景图像的自己的 CSS 类一样简单,但这行不通:

I thought it would be as easy as giving it your own CSS class with a background image, but that doesn't work:

.fw-button-edit {
    background-image: url(edit.png);
}

有什么建议吗?

推荐答案

我也可以推荐:

.ui-button .ui-icon.your-own-custom-class {
    background-image: url(your-path-to-normal-image-file.png);
    width: your-icon-width;
    height: your-icon-height; 
}

.ui-button.ui-state-hover .ui-icon.your-own-custom-class {
    background-image: url(your-path-to-highlighted-image-file.png);
    width: your-icon-width;
    height: your-icon-height; 
}

然后输入JS代码:

        jQuery('selector-to-your-button').button({
        text: false,
        icons: {
            primary: "you-own-cusom-class"   // Custom icon
        }});

它对我有用,希望对你也有用!

It worked for me and hope it works for you too!

这篇关于如何将自定义图标添加到标准 jQuery UI 主题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆