Skip to content

Instantly share code, notes, and snippets.

@tacamy
Created March 11, 2011 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tacamy/865607 to your computer and use it in GitHub Desktop.
Save tacamy/865607 to your computer and use it in GitHub Desktop.
devicePixelRatio=1.5以上のデバイスには全て2倍サイズの画像を縮小して表示させる。
/* devicePixelRatio=1 & devicePixelRatio未対応ブラウザ */
.className {
width: 100px;
height: 100px;
background: url(test@1x.png); /* 等倍の画像 */
}
/* devicePixelRatio=1.5以上 */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ratio: 1.5) {
.className {
background: url(test@2x.png); /* 2倍の画像 */
-webkit-background-size: 100px 100px; /* WebKit */
background-size: 100px 100px; /* WebKit以外 */
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment