1

i want to use a icon in jQuery Mobile on a span element...and i want to support retina display too. So how can i use a icon without giving my span a fix width? Should i use Media Queries and try to get it working that way or is there any "offical way" to do it?

Regards Nils

1 Answer 1

1

Here is my procedure for making custom icons in jQM.

You need 2x png's one that is 18x18 and another that is 36x36

In your css:

//non-retina
.ui-icon-amazing {
    background-image: url("custom.png");
}

//retina
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
    .ui-icon-amazing {
        background-image: url("custom-hd.png");
        background-size: 18px 18px;
    }
}

To use your new icon, which you have called 'amazing' simply use the appropriate data-icon= attribute

data-icon="amazing"

and the icon will get applied.

You get bonus points for base64 encoding your png directly into your stylesheet.

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

3 Comments

this is not exactly what i am looking for. i want to use my icon on a plain old span tag, and data-icon attribute doesn't apply to span tags. at least not for me.
Here's a very dodgy example, it doesn't use the data-icon attribute but is a clone of what gets generated out of the data-icon code jsfiddle.net/zbnqW
thanks...i tried ui-btn-icon all the time, but it's just the same like jQuery UI. :D

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.