Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CSS retina hairline, the easy way
div {
border: 1px solid #bbb;
.hairlines div {
border-width: 0.5px;
if (window.devicePixelRatio && devicePixelRatio >= 2) {
var testElem = document.createElement('div'); = '.5px solid transparent';
if (testElem.offsetHeight == 1)
// This assumes that 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
You can’t perform that action at this time.