Create a gist now

Instantly share code, notes, and snippets.

http://dieulot.net/css-retina-hairline – CSS retina hairline, the easy way – JS
if (window.devicePixelRatio && devicePixelRatio >= 2) {
var testElem = document.createElement('div');
testElem.style.border = '.5px solid transparent';
document.body.appendChild(testElem);
if (testElem.offsetHeight == 1)
{
document.querySelector('html').classList.add('hairlines');
}
document.body.removeChild(testElem);
}
// This assumes this script runs in <body>, if it runs in <head> wrap it in $(document).ready(function() { })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment