Created
June 12, 2012 01:40
-
-
Save to/2913882 to your computer and use it in GitHub Desktop.
Window Size, Media Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0"> | |
</head> | |
<body> | |
<pre id="out"></pre> | |
</body> | |
<script> | |
function checkSizes(){ | |
var out = [ | |
'window.devicePixelRatio: ' + window.devicePixelRatio, | |
'window.innerWidth: ' + window.innerWidth, | |
'window.innerHeight: ' + window.innerHeight, | |
'window.screen.width: ' + window.screen.width, | |
'window.screen.height: ' + window.screen.height, | |
'', | |
]; | |
var tests = { | |
'-webkit-device-pixel-ratio' : window.devicePixelRatio, | |
'-moz-device-pixel-ratio' : window.devicePixelRatio, | |
'device-pixel-ratio' : window.devicePixelRatio, | |
'device-aspect-ratio' : window.screen.width + '/' + window.screen.height, | |
'aspect-ratio' : window.innerWidth + '/' + window.innerHeight, | |
'width' : window.innerWidth + 'px', | |
'device-width' : window.screen.width + 'px', | |
'height' : window.innerHeight + 'px', | |
'device-height' : window.screen.height + 'px', | |
} | |
for(var prop in tests){ | |
var test = prop + ': ' + tests[prop]; | |
if(window.matchMedia('(' + test + ')').matches) | |
out.push(test); | |
} | |
document.getElementById('out').textContent = out.join('\n'); | |
} | |
checkSizes(); | |
window.addEventListener('resize', checkSizes, true); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
参考リンク。
viewport メタタグと @viewport 規則 - Dev.Opera
スマートフォンと画面解像度・ピクセル密度