3

I am working on an app for a client and am trying to create a button with a completely custom icon. The icon is 30px x 30px and transparent in the middle.

I have almost achieved what I want using this css code:

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

But there is a thin black circle that appears inside the icon, and also the icon image appears to be cut off:

enter image description here

I want to remove this circle and prevent the icon ? from being cut off. Also, I would like the question mark to be transparent instead of black, to show the image of the navigation bar beneath. If I try to set the background color to transparent though, the button appears entirely white:

enter image description here

How can I do this?

Update:

I tried applying this code:

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

And got this result:

enter image description here

I'm able to move the icon around by adjusting the top and left margins, but it's edges are cut off outside a frame centered on the black circle:

enter image description here

Update 2:

Here is the button I am using (Note that it is invisible here because it is a white button on a white background):

enter image description here

Here is the html code that I use to load the button:

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

1 Answer 1

7

This should fix the issue

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

Please ensure you are loading your application css file after jquery mobile css.

Edit:Here is a sample code based on the code you posted with the issue fixed

<!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(https://i.sstatic.net/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>

​A demo here - http://jsfiddle.net/LCsmt/

Let me know if that helps.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your suggestion but it didn't quite work. I've updated my question. I am loading the css for this page after the jquery mobile css (unless something is going on behind the scenes that I don't understand).
Any chance you can host the code somewhere with the actual icon you are using?.Then I can take a look and try to figure out the problem.Just need the code for the button alone.
I'm not sure that I understand you, but I think you are asking me to upload the button image. I added it to the question - note that it is not visible because it is a white button on a white background, but if you right click on the space in the question you will be able to save it. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.