使用自定义图标在jQuery Mobile中创建按钮

Dar*_*ren 3 jquery-mobile

我正在为客户端开发一个应用程序,我正在尝试创建一个带有完全自定义图标的按钮.图标为30px x 30px,中间透明.

我几乎已经使用这个css代码实现了我想要的东西:

/* info button override */
.ui-icon-info-page {
    background: url(images/G_help_icon_round.png) 50% 50% no-repeat;
    background-size: 30px 30px;
    background-color: black;
}
Run Code Online (Sandbox Code Playgroud)

但是图标内部出现了一个薄的黑色圆圈,图标图像似乎也被切断了:

在此输入图像描述

我想删除此圈并阻止图标?从被切断.此外,我希望问号是透明而不是黑色,以显示下方导航栏的图像.如果我尝试将背景颜色设置为透明,则按钮显示为全白:

在此输入图像描述

我怎样才能做到这一点?

更新:

我尝试应用此代码:

/* info button override */
.ui-icon-info-page {
    background: url(help.png) 50% 50% no-repeat;
    background-size: 30px 30px;
    width: 30px;
    height: 30px;
    margin-top: -15px !important;
    box-shadow: none;
    -webkit-box-shadow: none;
}
Run Code Online (Sandbox Code Playgroud)

得到了这个结果:

在此输入图像描述

我可以通过调整顶部和左边距来移动图标,但是它的边​​缘在黑色圆圈的中心框架外被切除:

在此输入图像描述

更新2:

这是我正在使用的按钮(请注意,它在这里是不可见的,因为它是白色背景上的白色按钮):

在此输入图像描述

这是我用来加载按钮的html代码:

<div data-role="header" data-position="fixed"> 
            <div><img border="0" src="images/G_iphone_navbar_logo.png" style="display:inline;"/> </div>          
            <a href="index.html" data-icon="refresh" class="ui-btn-left" data-transition="fade" data-iconpos="notext" data-theme="a"></a>
            <a href="info.html" data-icon="info-page" class="ui-btn-right" data-transition="flip" data-iconpos="notext" data-theme="a"></a>

</div>
Run Code Online (Sandbox Code Playgroud)

use*_*284 7

这应该解决问题

/* info button override */
.ui-icon-info-page {
    background: url(help.png) 50% 50% no-repeat;
    background-size: 30px 30px;
    width: 30px;
    height: 30px;
    margin-top: -15px !important;
    box-shadow: none;
    -webkit-box-shadow: none;
}
Run Code Online (Sandbox Code Playgroud)

请确保在jquery mobile css之后加载应用程序css文件.

编辑:以下是基于您修复问题时发布的代码的示例代码

<!DOCTYPE html>
<html>
    <head>
        <title>Page Title</title>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
        <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
        <style>
            #rightBtn .ui-btn-inner {
                width: 30px;
                height: 30px;
                margin: -3px;/*Modify to change icon position wrt the header*/
                border: none !important;
            }
            .ui-icon-custom {
                background: url(http://i.stack.imgur.com/AqicD.png) 50% 50% no-repeat;
                background-size: 30px 30px;
                width: 30px;
                height: 30px;
                box-shadow: none;
                -webkit-box-shadow: none;
                margin: 0 !important;
            }
        </style>
    </head>
    <body>
        <div data-role="header">
            <h1>Page Title</h1>
            <a href="index.html" data-icon="refresh" class="ui-btn-left" data-transition="fade" data-iconpos="notext" data-theme="a"></a>
            <a href="info.html" id="rightBtn" data-icon="custom" class="ui-btn-right" data-transition="flip" data-iconpos="notext" data-theme="a"></a>
        </div><!-- /header -->

        <div data-role="content"></div><!-- /content -->

        </div><!-- /page -->

    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这里有一个演示 - http://jsfiddle.net/LCsmt/

如果有帮助,请告诉我.