3

我正在为客户开发一个应用程序,并试图创建一个带有完全自定义图标的按钮。图标为 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;
}

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

在此处输入图像描述

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

在此处输入图像描述

我怎样才能做到这一点?

更新:

我尝试应用此代码:

/* 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;
}

并得到了这个结果:

在此处输入图像描述

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

在此处输入图像描述

更新 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>
4

1 回答 1

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;
}

请确保您在 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>

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

让我知道这是否有帮助。

于 2012-05-13T17:00:30.563 回答