Solved

Change background size of sprites

Posted on 2014-02-15
5
240 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
Comment Utility
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
Comment Utility
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
Comment Utility
ok thanks dinosaur

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

Cheers
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Joomla Website Malfunction 9 47
css question 1 31
Best Practice CSS floating images 2 14
jQuery Canlendar click function 5 17
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now