I want to find the ratio between CSS pixels and device pixels.
Edit: I should have realized that this is just zoom level. I\'ve added an answer to t
There is a much better CSS/JS solution:
/** sample media query for pixel-ratio=2" **/
@media
(-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {
.pixel-ratio-holder:before {
content: "2";
}
}
function jsPixelRatio(){
return window.getComputedStyle(document.querySelector('.pixel-ratio-holder'), 'before').getPropertyValue('content').replace(/[^a-z]/g,'') * 1;
}