Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-zoomable webview that works at both iPhone and iPhone4 resolutions

I want to have a webview that has a single HTML and a single CSS file, shows graphics at the same size, but native resolution for each.

My existing webviews, designed for 320x480 seems to scaled up well (crisp text and border-radius for instance), though images are at half res in the iPhone4 simulator. How do I simulate the native image loading behaviour where a graphic or it's double res version is chosen automatically with HTML, CSS, or JS? (hopefully not JS)

I'm currently using a viewport declaration like so:

<meta content='initial-scale=0.5; maximum-scale=1.0; minimum-scale=0.5; user-scalable=0;' name='viewport' /> 

This zooms out and image pixels are 1:1 with display pixels, but it also scales down everything else. And of course makes it tiny on the smaller iPhone display.

I have a feeling this has something to do with some sort of viewport size media query?

like image 372
Alex Wayne Avatar asked Jan 24 '26 03:01

Alex Wayne


1 Answers

This will load a specific stylesheet for iPhone 4:

<link
    rel="stylesheet" type="text/css" href="/css/style.css" media="only screen and (-webkit-min-device-pixel-ratio: 2)"
/>
like image 176
Kolin Krewinkel Avatar answered Jan 25 '26 19:01

Kolin Krewinkel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!