Skip to content

Instantly share code, notes, and snippets.

@hiloki
Forked from vantguarde/page.html
Created May 2, 2011 07:55
Show Gist options
  • Save hiloki/951285 to your computer and use it in GitHub Desktop.
Save hiloki/951285 to your computer and use it in GitHub Desktop.
<!--
see http://www.modernizr.com/docs/#backgroundsize
-->
<script src="modernizr-1.7.min.js"></script>
/* devicePixelRatio=1 & devicePixelRatio未対応ブラウザ */
.className {
width: 100px;
height: 100px;
background: url(test@1x.png); /* 等倍の画像 */
-webkit-background-size: 100% 100%; /* 古いWebKit用 */
background-size: 100% 100%; /* 100%にしといて .className の幅と高さを参照 */
}
/* devicePixelRatio=1.5以上 */
@media (-webkit-min-device-pixel-ratio: 1.5),
(min--moz-device-pixel-ratio: 1.5),
(-o-min-device-pixel-ratio: 3/2) {
.backgroundsize .className {
background: url(test@2x.png); /* 2倍の画像 */
}
}
@hiloki
Copy link
Author

hiloki commented May 2, 2011

https://gist.github.com/886266 で moz--min-device-pixel-ratio となっていたが、
正しくは min--moz-device-pixel-ratio のはず。
たまたま device-pixel-ratio のことを調べていてぶつかったのでforkしてみた。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment