Handleling image size on multiple device display o

2019-05-22 19:34发布

问题:

I'm building a new app with this great tool and i have a question to solve.

What is the best way to handle imnage size for multiple scren and multiple devices.

Apple = retina and non-retina Android = ldpi, mdpi, hdpi, xhdpi, xxhdpi and tablets (all this with multiple screen resolution) BlackBerry10 = one resolution (but not equal to the others) WindowsPhone8 = one resolution (but not equal to the others)

For this case, what is the best way ?

  1. Use SVG images (Optimizacion, perfomance, size of app) ??

  2. Dedicate CSS tags for device pixel ratio (CSS Image Replacement) (the designer can kill me :smile: lol ) see the list http://bjango.com/articles/min-device-pixel-ratio/

  3. CSS Sprite sheet

  4. Another way

Before the decision, think in what is the best to apply in all devices.

Thanks in advance

回答1:

There really isn't a single way to do this since each implementation of an image will require a different approach depending on its purpose. SVGs are great but not everything works as an SVG.

Media queries will be your ally.

See this: supporting multiple resolution and density of images in phonegap

and this for an alternate approach: Angular.js data-bind background images using media queries

There are also some nice polyfills for the html5 picture element which you might find useful.

See: https://github.com/scottjehl/picturefill

...and its angularjs directive implementation https://github.com/tinacious/angular-picturefill