On a recent responsive design we were working on, we ran into a bit of an issue regarding our sprites and mobile devices. We noticed that when the sprite sheets got to a certain pixel height, they stopped showing up. YIKES.
The project in question was for our client Pecking Order, who wanted a site with a very handmade feel – perfect for a pretty extensive sprite use.
As the project went on, our sprite got to be pretty large – close to 6000px deep. The tricky part of this is that the sprite graphic was showing up in all our emulators, but not when viewing the site on our live sandbox links. We didn’t want to have to break stride and rebuild our sprites in mid-project, so we figured out a quick fix – and made all of our 7th grade algebra teachers happy in the process.
If you’ve been injured in a motorcycle accident, contact the experienced Motorcycle Accident Lawyers Philadelphia at www.kaplunmarx.com. Medical malpractice occurs when an injury or death occurs because a medical professional or healthcare provider, through a negligent act or omission, provides care or treatment that falls below the acceptable standard of care. You can ask assistance and advise from a lawyer specializing in medical malpractice law.
The quick solution to the problem was this: dev as you see fit, and just let your sprites grow however large you want them to grow. When you’re ready to launch, grab your master sprite .psd and do the following…
1. Draw horizontal guides at an exact horizontal proportion all the way down. Personally, I would recommend 2000px.
2. Then, create NEW sprites by cropping your master sprite at a slightly higher height than the 2000px height – doesn’t really matter, however tall you feel comfortable working with. However, lock your top cropping at those horizontal guides. Now, you’ll have three new sprites, all of varying heights – but all originating from points falling exactly 2000px down from the master. Don’t worry, this will make sense in a minute.
3. Name these new sprites the same name as your master but appended – ie: if your mastersprite is named “mastersprite.png,” name your new cropped ones “mastersprite-top.png,” “mastersprite-mid.png” and “mastersprite-btm.png.” Like this…
4. Now, open your CSS document and do a quick scan on all your sprite graphics.
• Do a find/replace to change ALL your sprite names to “mastersprite-top.png”
• When you find one that has a y-value of greater than -2000px, change the name to -mid.png and subtract 2000 from that y-value. So…
background: url("../images/mastersprite.png") no-repeat -300px -3039px;
background: url("../images/mastersprite-mid.png") no-repeat -300px -1039px;
5. Repeat the same process for any item with a y-value of greater than -4000px, changing the name to -btm.png and subtracting 4000 from that y-value.
6. Then, do future you a favor and notate your CSS sheet like so:
Helpful note: when building sprites for mobile, images should not be any deeper than 2560px (iOS especially has an issue with sprites larger than 2560px deep). iPad will render these sprite graphics in landscape mode but _not_ in portrait. Devices rendering at 420px and lower are spotty at best. Emulators (including Adobe Shadow / Edge Inspect and Safari's User Agent will not pick this up.
At this point you might be thinking to yourself “Wait – having multiple sprites on a project… doesn’t that kinda negate the entire purpose of spriting?” No, not at all. It’s much better for site optimization to deal with three sprites like I’ve outlined, rather than deal with hundreds of small background images that have to get loaded individually.
Now, go find your 7th grade algebra teacher and tell her you were wrong – you did end up using that math in your everyday life. 🙂
In addition, find your apheresis machine in easy ways. All you need to do is to go here in our website or give us a call today.