Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change background size of sprites

Posted on 2014-02-15
5
Medium Priority
?
275 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 1500 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

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

610 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