Solved

Change background size of sprites

Posted on 2014-02-15
5
252 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 29

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

738 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