Em /ïŒ ã®ãã©ã³ãã¯ãã¹ãŠã®äººã«é©ããŠããŸã-IEãŠãŒã¶ãŒã¯ãµã€ãºã倧ããããããšãã§ããããã¹ããèŠãããããããã«ãã©ãŠã¶ãŒã®ããã©ã«ãã®ãã©ã³ããµã€ãºã倧ããããããšã奜ã¿ãããã®ã¿ã€ãã»ãã¿ãŒã®æšæºã§ãã
çæïŒ...ãªããªã£ãããã§ãããïŒ
ãããããŠãŒã¶ãŒã®ç»é¢è§£å床ãæšæºã®96 dpiã«èšå®ãããŠãããã120ã«èšå®ãããŠããå Žåã¯ã©ãã§ããããïŒ
ãã©ã³ãã倧ãããµã€ãã¯ããã¶ã€ããŒãæããã»ã©çŸãããããŸãããçµå±ã®ãšããããµã€ãå šäœã§ã¯ãªããã©ã³ãã®ã¿ãæ¡å€§çž®å°ãããŸãã ãŸããç¹ã«ã©ãããããã§ã¯ã120dpiã®è§£å床ãããäžè¬çã«ãªã£ãŠããŸãïŒ ã©ãããïŒ pxã«æ»ããŸããïŒ
ããïŒ
泚æïŒ 2013幎çŸåšããã®èšäºã¯å€ãããã®æ å ±ã¯çè«çãªç¥èã«ã®ã¿åœ¹ç«ã¡ãŸãã æ¬çªç°å¢ã§ã³ãŒãã䜿çšããªãã§ãã ããïŒ åœŒã¯ããå¿ èŠãããŸããã
* Operaã«ã¯ãã®ãã°ã¯ãªããªããŸãããäžè¬çã«ã¯ãããããå¥ã®ãšã³ãžã³ïŒWebkitïŒã«æèŒãããäºå®ã§ãã
* IE6ããã³7ã¯æ¢ã«å±¥æŽé ç®ã§ãããã»ãšãã©ã®äººããããããµããŒãããŠããŸããã
*å®éãEMãè£ã人ã¯ã»ãšãã©ããŸãããã»ãšãã©ã®å Žåãã¬ã€ã¢ãŠãã§ã¹ã¿ã€ã«ã®ç¬ç«æ§ïŒBEMã¡ãœããïŒã®ããã«PXãåã³äœ¿çšããŸãã
ããã§ãåé¡ãç¹å®ããŸãã
Windowsã§ã¯ãç»é¢è§£å床ã96 dpiãè¶ ãããšãIEâ€7ãšOperaã¯ããã©ã«ãã®ãã©ã³ããµã€ãºãæ¯äŸçã«å¢å ãããŸãã
ããã«ãããéåžžãåºå®å¹ ã®ãµã€ãã§äžå¿«ãªãã¶ã€ã³ã®æªã¿ãçºçããå¯èœæ§ããããŸãã
Firefoxããã³Safari / Chromeã¯ç»é¢dpiãç¡èŠããŸãã
ãŽã -èšèšè ãæå³ãããšããïŒ
ãŽã -120dpiïŒ
åºå®å¹ -ãã¶ã€ããŒãæå³ãããšããïŒ
åºå®å¹ -120dpiïŒ
ã©ããŒã¢ãã¯ã¢ããã§ã¯ããµã€ãºãæ¡å€§ããŠãäžè¬ã«åé¡ã¯çºçããŸããããåºå®å¹ ã®ãµã€ãã§ã¯ãå²ãåœãŠãããçãåã«æ¡å€§æåãåãŸããªãå ŽåããããŸãã 倧ããªãµã€ãºã¯ãæ®ãã®æªæ€èšŒã®ã°ã©ãã£ãã¯ã®æšªã«ãããã«èŠããŸãã
ãã©ã³ããµã€ãºãå¢å ãããšã©ããªããŸããïŒ
ååãšããŠããã©ã³ãã®ã¿ãæ¡å€§ãããŸãã ãµã€ããåå²ãããããã¯ãå¢å ããŸãïŒãµã€ãºãem /ïŒ ã§æå®ãããŠããå ŽåïŒ ããã°ã©ãã£ãã¯ã¯å¢å ããŸãã ïŒ
ããã¯ããµã€ãºå€æŽå¯èœãªãã©ã³ããæŸæ£ããå¿ èŠããããšããæå³ã§ã¯ãããŸããïŒ
å®éãéåžžã«å€§ããªã¢ãã¿ãŒã§ã¯ã120 dpiã¯æµè¡ã§ã¯ãªãå¿ éåã§ããå°ããªæŽ»åã¯èŠã«ããã§ãã ãŸãããŠãŒã¶ãŒã¯ããã®ç¹å®ã®ããŒãžãšäžè¬çãªãã©ãŠã¶ãŒèšå®ã®äž¡æ¹ã§ããã¹ãŠã®ãµã€ãã§ãã©ã³ããµã€ãºã倧ãããªãããã«ããã©ã³ããµã€ãºã倧ãããããã ãã§ãã
ãµã€ãã®äœ¿ãããããäœäžãããããã«ã人ã ãé«ãå£ããªãã§ãã ããã ãããããã¶ã€ããŒãæå³ãããšããããµã€ãã¯èŠãç®ãçŸããã¯ãã§ãããªããªãã圌ãã¯æŽæã§äŒãããã§ãã
CSSã䜿çšãããšããŠãŒã¶ãŒã®è§£å床ã確èªããããã«æ¯äŸããŠãã©ã³ããµã€ãºãçž®å°ã§ããŸãã
html {font-size: 68.75%} /* 11px */ @media all and (min-resolution: 120dpi) { html {font-size: 55%} /* : 68.75/(120/96) */ }
IE6 / 7ã®å Žåã次ã®ã³ãŒããå¿ èŠã§ãã
#header { scrollbar-track-color:expression( this.runtimeStyle.scrollbarTrackColor = "#fff", ((screen.deviceXDPI/screen.logicalXDPI) == 1) ? (document.body.style.fontSize = 1/(screen.logicalYDPI/96) +'em') : false ); }
ããã¯1åéãã®1ã€ã®åŒã§ãç»é¢ã®dpiã«æ¯äŸããŠåºæ¬ãµã€ãºãå€æŽããŸãã
ããã«è©³ããåæããŠã¿ãŸãããã
#header
ããã«ã¯ãã¬ã€ã¢ãŠãå ã®æ¢åã®ãããã¯ã®IDãæå®ã§ããŸãã ããã£ãããããããã ãã«å¿ èŠã§ããè¡šçŸèªäœãããã£ã®ã¹ã¿ã€ã«ãå€æŽããŸãã
scrollbar-track-color
color-ãæ®å¿µã§ã¯ãªãããããã㣠IEã§ã¯ãè²åããããã¹ã¯ããŒã«ããŒãã¡ããªã®ç¬èªã®ããããã£ã䜿çšããŠããŸãã èŠçŽ ã«ã¹ã¯ããŒã«ããŒããªãå ŽåïŒã€ãŸãããªãŒããŒãããŒå€ã衚瀺ïŒããã©ã«ãïŒãŸãã¯é衚瀺ïŒã®å Žåããã®ããããã£ã¯ãããã¯ã®è¡šç€ºã«åœ±é¿ããŸããã
screen.deviceXDPI
2-ãã©ãŠã¶ãŒã®ç»é¢ã®å®éã®dpiã
screen.logicalXDPI
3-ç»é¢ã®æšæºdpiïŒWindowsã§èšå®ãéåžž= 96ïŒ
éåžžãscreen.deviceXDPI == screen.logicalXDPIã ãã ããäŸå€ã¯ä»¥äžã«ãããŸãã
IE6 / 7ã¯ãé«è§£å床ã®ç»é¢ã§æ¯äŸçã«æ¡å€§çž®å°ã§ããŸãã
ããããã£
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\
UseHR = dword:00000001
ããããæ åœããŸãã
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\
UseHR = dword:00000001
MSDN 4ã¯ãé«è§£å床ã¢ãã¿ãŒã®ã¡ãŒã«ãŒããã®ãã©ã¡ãŒã¿ãŒãèšå®ã§ããããšãäŒããŠããããã§ãã
次ã®ããã«ãªããŸãã
ãºãŒã ãæå¹ãªIEïŒUseHR = 1ïŒïŒIEãºãŒã ãªãïŒUseHR = 0ïŒïŒ
ãã®ãªãã·ã§ã³ãæå¹ã«ããŠã¹ã±ãŒãªã³ã°ãéæããããšã¯ã§ããŸããã§ããããå®å šã«åçããIEã¹ã±ãŒã«ãã¡ã¯ã¿ãŒã確èªãã1ã®å ŽåïŒã€ãŸããã¹ã±ãŒãªã³ã°ããªãã®å ŽåïŒã ããããã£ã®ãµã€ãºãæ¯äŸçã«å€æŽããŸãã
document.body.style.fontSize = 1/(screen.logicalYDPI/96) +'em'
æ¬æã®ãã©ã³ããµã€ãºãïŒã«ã¹ã±ãŒãã§ïŒèªåçã«å€æŽãããšãä»ã®ãã¹ãŠã®ãã©ã³ãã®ãµã€ãºãå€æŽãããŸãã
IE 5ã¯ãæ®å¿µãªããscreen.deviceXDPI / screen.logicalYDPIããµããŒãããŠããªãããããã®ã³ãŒãã¯æ©èœããŸããã
IE8ã¯ã©ãã§ããïŒ
IE8ã§ã¯ããã¹ãŠãéåžžã«çŸãããšã¬ã¬ã³ãã«è¡ãããŸããããã©ãŠã¶ãŒã¯ãç»é¢ã®dpi 5ã«æ¯äŸããŠããŒãžã®ã³ã³ãã³ãå šäœãå¢ãããŸãã
96dpi | 120dpi | 144dpi |
---|---|---|
screen.deviceXDPIãscreen.logicalXDPIãããã³ããŒãžãºãŒã ã«é¢ããåæ çãªäœè«
IE8ã§ã¯ããã«ããŒãžãºãŒã ãæå¹ã«ãããšãscreen.deviceXDPIã®å€ãå€æŽãããŸãã 125ïŒ ã®å ŽåããºãŒã = 120ã150ïŒ -144ã100ïŒ ã®å ŽåïŒã¹ã±ãŒãªã³ã°ãªãïŒãscreen.deviceXDPIã¯96ã«æ»ããŸããWindowsã®dpiã¯åé¡ã§ã¯ãããŸããã
ãããïŒscreen.deviceXDPI == screen.logicalXDPIïŒã«å¿ èŠãªãã§ãã¯ã§ãïŒ
ããã¯ãIE8ã®å³äžé ã«ãããŠãŒã¶ãŒã[ããŒãžã®ãºãŒã ]ãã¯ãªãã¯ããŠå€æŽããå Žåã§ãã
ãããã8-keã®screen.logicalYDPIã¯æããã«äžå®ã®æ°ã§ãããç§ã®ãã¹ãã§ã¯åžžã«96ã§ããã
7-keããã³6-keã§ã¯ããã¹ãäžã«ãããã®å€ã®äž¡æ¹ãWindowsã®èšå®ã«å¿ããŠã®ã¿å€åããŸããã IE7ã®ããŒãžãºãŒã ã¯ãã©ã¡ãã®ããããã£ã®å€ãå€æŽããŸããã§ããã
å€ä»£ã®ãµã€ãã«æŸèæãæžããŠãããšãã«èšäºãæžããåŸãç§ã¯å¶ç¶ãããçºèŠããŸãã:)
ãšããã§ãIE8ã®ããŒãžãºãŒã ã¯IE7ãããåªããŠããŸãã
IE7ãã«ããŒãžãºãŒã ïŒ
IE8ãã«ããŒãžãºãŒã ïŒé©å¿ãºãŒã ïŒïŒ
æ°Žå¹³ã¹ã¯ããŒã«ã¯ãåã®å¹ ãåºå®ãããæ¹è¡ãæ°ããå Žæã«æ¿å ¥ãããå ŽåïŒã¹ã±ãŒãªã³ã°åŸïŒã«ã®ã¿è¡šç€ºãããããã«ãªããŸãããäžè¬ã«ãFFããã³Operaã§ã®çºçãšéåžžã«ãã䌌ãŠããŸãã
ãã®ã¡ã«ããºã ã¯ã¢ãããã£ããºãŒã ãšåŒã°ããŸãã詳现ã«ã€ããŠã¯ãIE 6éçºè ã®ããã°ãã芧ãã ããã
IE6 / 7ã§ã¯ã次ã®ããã«åæ§ã®åäœãå®çŸã§ããŸãã
div#header { scrollbar-track-color:expression( this.runtimeStyle.scrolbarTrackColor = "#fff", (((screen.deviceXDPI/screen.logicalXDPI) == 1) && (screen.deviceYDPI > 96)) ? ( document.body.style.fontSize = 1/(screen.logicalYDPI/96) +'em', document.body.style.zoom = screen.logicalYDPI/96 ) : false ); }
120 dpi css-zoom IE6 / 7ïŒ
ããã¯ã125ïŒ ãã«ããŒãžãºãŒã IE7ãšã¯ç°ãªããŸãã
IE7ã®ãã«ããŒãžãºãŒã ã¯ãhtmlå šäœïŒæ°Žå¹³ã¹ã¯ããŒã«ã衚瀺ãããããïŒãå¢å ãããcssãä»ããŠæ¬æã®ã¿ã«cssãºãŒã ãèšå®ã§ããŸãã
css-zoomã§ã¯ãIE7ã®ãã«ããŒãžãºãŒã ã§ã®æ°Žå¹³ã¹ã¯ããŒã«ã¯ãããŸãããããã©ãã·ã¥ãªããžã§ã¯ãã«ã¯åé¡ããããŸããããŠã¹ãªããžã§ã¯ãã«ã«ãŒãœã«ãåããããšæ¶ããéšåçã«è¡šç€ºãããããããããããã«ãªããŸãã
ãã©ãã·ã¥ã®ãããªãªããžã§ã¯ãã䜿çšããªãå Žåããã®ã¡ãœããã䜿çšã§ããŸãã
å¥åŠãªããšã«ãããã¯css zoomããããã£ãæå³ãããšããã«äœ¿çšãããŸããªã±ãŒã¹ã§ãããã¬ã€ã¢ãŠãã®èšå®ã§ã¯ãããŸããã
CSS3 Media Queriesãç解ããFirefox 3.1ã¯ã©ãã§ããïŒ
ãµã€ãºã120dpiæžããã«ã¯ãCSS3ããããã£
min-resolution
ã䜿çšããŸãã
Firefox 3.1ã¯ãããç解ããŠé©çšããŸãã ãã ããåæã«ããã©ã³ããµã€ãºã¯å¢å ããŸããã ãã®ããããã®äžã®ãã©ã³ãã¯å¿ èŠä»¥äžã«ãªããŸãïŒ
ä¿®æ£ããŸãïŒ
html {font-size: 68.75%} /* 11px==1em, = 11px x Xem */
@media all and (min-resolution: 120dpi) {
html {font-size: 55%}
html, x:-moz-any-link {font-size: 68.75%}
}
x:-moz-any-link
ã¯ã-moz-any-linkç䌌ã¯ã©ã¹ãæã€ååšããªãxèŠçŽ ã®éžæã§ãã Geckoãã©ãŠã¶ãŒã®ã¿ããã®æ¬äŒŒã¯ã©ã¹ãç解ããæ®ãã¯è¡å šäœãç¡èŠããŸã7 ã
Opera 9ã®ç°åžžãªäžå ·åïŒ<9.6ïŒ
FF3.1ã®ä¿®æ£ãè¿œå ããåŸãOperaã¯min-resolutionã®ã«ãŒã«120dpiã®çŽåŸã«css-adãç¡èŠãå§ããŸãããã€ãŸã 次ã®ã³ãŒãããããŸãã
html {font-size: 68.75%} @media all and (min-resolution: 120dpi) { html {font-size: 55%} html, x:-moz-any-link {font-size: 68.75%} } body,table,input,label,textarea,button,select {color: #000; font: normal 1em/1.3 Tahoma, Geneva, sans-serif}
body
å§ãŸãã«ãŒã«ã¯Opera 9ã§ã¯ç¡èŠãããŸãã
ããã«ãOpera 8ããã³9.6ã§ã¯ããã¹ãŠåé¡ãããŸããã
ä¿®æ£ããŸãïŒ
html {font-size: 68.75%} /* 11px==1em, = 11px x Xem */
@media all and (min-resolution: 120dpi) {
html {font-size: 55%}
html, x:-moz-any-link {font-size: 68.75%}
}
#for-opera927 {/* dont' remove! */}
120dpiã®ãµã€ãã®å€èŠ³ã96ã«ãããã©ããã¯ããªã次第ã§ã
ç¹°ãè¿ããŸããããµã€ãã®éå§åœ¢åŒã«ã€ããŠè©±ããŠãããšããã§ããç»é¢è§£å床ã120dpiã®ãŠãŒã¶ãŒã¯ãã»ãšãã©ã®ãµã€ãã96ãšãŸã£ããåãããã«è¡šç€ºããŸãïŒã»ãšãã©ã®ãµã€ãã¯åºå®ãµã€ãºã§æ§æãããŠããããïŒã emã«æããããŸãããšãããã«æ¡å€§è¡šç€ºãããŸãã ããã«ããã©ã³ããµã€ãºã®ã¿ãå¢å ããã°ã©ãã£ãã¯ã¹ã¯å ã®ãŸãŸã«ãªããŸãã åæãã-ãµã€ãã¯ãã¶ã€ããŒãåœåæå³ããã»ã©çŸããã¯ãããŸããã
ããã§ã¯ããŠãŒã¶ãŒãæå³ãããšããã«è¡šç€ºããªãã®ã¯ãªãã§ããïŒ
ããã¯ä»»æã®ç§ã§ãã®äžã®ãã©ã³ããµã€ãºãå¢ããããšãã§ããŸãã
ãšããã§ããŠãŒã¶ãŒèªèº«ã120dpiãèšå®ããã®ã¯äºå®ã§ã¯ãããŸããã
ãã®ãããªèšå®ãããã©ã«ãã§ããã©ããããããè³Œå ¥ããã ãã§ããã
ãŸãããŠãŒã¶ãŒãFFãŸãã¯SafariïŒdpiã§ã¯ç¡èŠãããŸãïŒã®åºæ¬ãã©ã³ããµã€ãºã倧ããããå ŽåãèŠããããªããŸããïŒ
ä¿®æ£ããªããã°ãemãå«ããµã€ãã«ã¯å·šå€§ãªãã©ã³ãã䜿çšãããŸãã
ãããŠãIE8ã§ã®ã¿ããµã€ãã¯çŸããæ£ç¢ºã«ã¹ã±ãŒãªã³ã°ãããŸãã
å°æ¥ã®èšŒæ ã¯ã©ãã§ããïŒ ãã©ãŠã¶ã®å°æ¥ã®ããŒãžã§ã³ã«åé¡ã¯ãããŸããïŒ
è¿ãå°æ¥ãåé¡ã®çºçã¯ã»ãšãã©ãããŸããã
ä¿®æ£ã¯ã次ã®å Žåã«ã®ã¿å¿ èŠã§ãã
- Safariã¯ãæå°è§£å床ã®CSS3ããããã£ãç解ãå§ããŸãããç»é¢ã®dpiã«å¿ããŠãµã€ãºã¯æ¡å€§ããŸããã
ãã®å ŽåãFF3.1ã«ã€ããŠèšè¿°ããã®ãšåæ§ã®ã«ãŒã«ã§ã³ãŒããè£å®ããŸãã
- Internet Explorer 9ã¯æå°è§£å床ã®ç解ãéå§ããIE8ãšåãé©å¿ãã«ããŒãžãºãŒã ãç¶æããŸãã
ããã¯ãæ¡ä»¶ä»ãã³ã¡ã³ã8ãä»ããŠIEâ¥9ãä¿®æ£ããããšã§ä¿®æ£ãããŸãã
- Operaã¯ãé«dpiã§ãã©ã³ããµã€ãºã倧ãããã代ããã«ããã«ããŒãžãºãŒã ã䜿çšãå§ããŸãã
ããã¯ãFF3.1ã§èšè¿°ãããã®ãšåæ§ã®ã«ãŒã«ã§åŠçãããŸãã
ã ãããããã«æ¢è£œã®ãœãªã¥ãŒã·ã§ã³ããããŸãïŒ
html {font-size: 68.75%} /* - */ @media all and (min-resolution: 120dpi) { html {font-size: 55%} /* : 68.75/(120/96) */ html, x:-moz-any-link {font-size: 68.75%} /* - */ } #for-opera927 {/* dont' remove! */}
IE6 / 7ã®å ŽåïŒ
#header { scrollbar-track-color:expression( this.runtimeStyle.scrollbarTrackColor = "#fff", ((screen.deviceXDPI/screen.logicalXDPI) == 1) ? (document.body.style.fontSize = 1/(screen.logicalYDPI/96) +'em') : false ); }
UPDïŒäœããã®çç±ã§Opera 10.5+ã¯ã«ãŒã«
@media all and (min-resolution: 120dpi) { ... }
å¿çããŸããããããã¯ã¯å察ã§ããã presto 2.5ã§ã®ã¿ãµããŒããããŠãããšæžãããŠããŸãã ãåã«åããïŒïŒã ç§ã¯ããŸããŸãªãªãã·ã§ã³ãè©Šããã°ãŒã°ã«ã§æ€çŽ¢ããOperaãã©ãŒã©ã ãæ€çŽ¢ããŸããããäœãèŠã€ãããŸããã§ãã/ããã¯åœ¹ã«ç«ã¡ãŸããã§ããã ä»æ§ããå€æãããšãã³ãŒãå ã®ãã¹ãŠãæ£ããã§ãã çŸåšãOperaãä¿®æ£ãããŸã§åŸ ã€å¿ èŠããããŸãã 幞ããªããšã«ã120dpiã®åé¡ãäžè¬çã§ãã西éšã§ã¯ãOperaã¯ã»ãšãã©ãããŸãããOperaã人æ°ã®ããããã§ã¯ã120dpiã®åé¡ã¯ã»ãšãã©ãããŸãã:)
UPD2ïŒpepelsbeyã«ãããšãOperaã¯æå°è§£å床ããµããŒãããªããªã£ããããã¡ã€ã³ã®csså ã®ã³ãŒãã¯ãªãã«ããã ãã§ãã IE6 / 7çšã®ã³ãŒããæ®ãããšãã§ããŸãã
泚ïŒ
- Pavel KornilovïŒInternet Explorerçšã®Thin CSSïŒåŒïŒ
- MSDNïŒdeviceYDPIããããã£
- MSDNïŒlogicalYDPIããããã£
- MSDNïŒé«DPIç»é¢ã®ã¹ã±ãŒã«ã®èª¿æŽ
- MSDNïŒWebããã倧ããããïŒDPIã¹ã±ãŒãªã³ã°ãšInternet Explorer 8
- MSDNïŒInternet Explorer 8ããã³é©å¿ãºãŒã
- CSS2ä»æ§ã«ããã°ããã©ãŠã¶ãŒã¯ãã»ã¬ã¯ã¿ãŒã§ãªãã¿ã®ãªããã®ãèŠã€ãã£ãå Žåã«ã¹ã¿ã€ã«ãç¡èŠãã矩åããããŸã
- MSDNïŒæ¡ä»¶ä»ãã³ã¡ã³ãã«ã€ããŠ
dpiã®è©³çŽ°ïŒ