I believe what you're looking for is -webkit-min-device-pixel-ratio
.
The -webkit-device-pixel-ratio feature is specified as a value. It is a range feature, meaning that you can also use the prefixed -webkit-min-device-pixel-ratio and -webkit-max-device-pixel-ratio variants to query minimum and maximum values, respectively. (source)
As a test of this I set up the following fiddle, which will output -webkit-min-device-pixel-ratio
(with credit to this). Also stack snippet below.
https://jsfiddle.net/3w5rq8pj/10/
I tested this on several devices with the following results:
- Actual iPhone 7 Plus / Result 3
- Macbook Pro with Retina Display / Result 3
- Lenovo Thinkpad (ie) / Result 0
- Emulated iPhone 6 Plus on BrowserStack via Macbook Pro with Retina / Result 3
- Emulated iPhone 6 Plus on BrowserStack via Lenovo Thinkpad / Result 3
In all these cases the Browserstack emulators returned the proper results (which honestly suprised me).
I also re-ran all the tests but removed -min from the query in the javascript, and every single test case returned 0.
function guess() {
var ls, l=0, h=8192, c=parseInt((l+h)/2), i=20;
while (i > 0 && (c - l >1) && (h - c>1)) {
i--; // Shouldn't take more than 13 guesses, but in case of bugs!
if (window.matchMedia('(-webkit-min-device-pixel-ratio: ' + c + ')').matches) {
l=c; ls=0;
} else {
h=c; ls=1;
}
c = parseInt((h+l)/2);
}
c -= ls;
document.getElementById("result").innerHTML = "min pixel ratio: " + c;
}
guess();
<div id="result"></div>