Solved

Change background size of sprites

Posted on 2014-02-15
5
250 Views
Last Modified: 2014-03-14
Hi

I have icons that use a sprite. They are 60px by 60px. For mobile i want to reduce them down to 35px by 35px.

I dont really want to create seperate sprite image for mobile .

Is this possible with CSS?

Thanks
0
Comment
Question by:coolispaul
5 Comments
 
LVL 28

Expert Comment

by:sammySeltzer
ID: 39861738
One way I know how is to define the dimensions in css:

.bg_image_resize
{
    background-image:url('/yourfolder/yourimage.jpg');
    width:35px;
    height:35px;
}

Open in new window


Then usage:

<span class="bg_image_resize"></span>

It may be something other than <span> since no code is shown
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 39861739
Trying to avoid using different dimensioned sprites is almost certainly not going to get anything reliable.  The closest thing might be to use transform:scale() after detecting the device, or through a media query but that is 100% guaranteed to have cross-browser, cross-browser versions and cross-device issues that will never be fully resolved because each new device will add new challenges.

It takes about 30 seconds in any graphics program to create a new version and about 10 seconds to ad a media query to the CSS; while trying to get to work without using new versions of the graphics could take weeks and will never be as reliable as using additional sets of sprites.

BTW mobile devices do not use a standard size or specification for the size of a pixel.

Cd&
0
 

Author Comment

by:coolispaul
ID: 39864236
ok thanks dinosaur

I'll use different sprites then. I thought this might be best...

Cheers
0
 
LVL 58

Expert Comment

by:Gary
ID: 39928731
I've requested that this question be closed as follows:

Accepted answer: 500 points for COBOLdinosaur's comment #a39861739

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Html fieldset fix its height and width 4 43
convert Systemjs to Webpack 3 72
Easy css question moving title underneath an image 4 27
Sending ASP to server side 8 28
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question