What happens when you increase the font size:
As a rule, only the font is increased. The blocks into which the site is divided can also increase (if their sizes are also given in em /%), but the graphics do not increase !This does not mean that we should abandon the variable font sizes!
After all, on really large monitors, 120 dpi is not a fad, but a necessity - the small print is hard to see. Yes, and the user may just want to increase the font size - both on this particular page, and in general in the browser settings - so that it is larger on all sites.
We should notbreak the buzz on peopleto reduce the usability of the site. But the site should also look beautiful, as the designer intended, because they are met in clothing.
html {font-size: 68.75%} /* 11px */ @media all and (min-resolution: 120dpi) { html {font-size: 55%} /* : 68.75/(120/96) */ }
#header { scrollbar-track-color:expression( this.runtimeStyle.scrollbarTrackColor = "#fff", ((screen.deviceXDPI/screen.logicalXDPI) == 1) ? (document.body.style.fontSize = 1/(screen.logicalYDPI/96) +'em') : false ); }
This is a one-time 1 expression, it changes the base size in proportion to the dpi of the screen.#header
- here can be the id of any block existing in the layout. We need it only to “catch on”, the expression itself changes the styles for the body.scrollbar-track-color
- any property that is “not sorry”. I use the proprietary property of IE, from the family that defines the color of the scroll bars. If the element does not have scroll bars (i.e., the overflow value is visible (by default) or hidden), then this property does not affect the display of the block in any way.screen.deviceXDPI
2 is the actual screen dpi in the browser.screen.logicalXDPI
3 - standard screen dpi (as set in Windows, usually = 96)HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\
UseHR = dword:00000001
is responsible for this. HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\
UseHR = dword:00000001
document.body.style.fontSize = 1/(screen.logicalYDPI/96) +'em'
IE 5, unfortunately, does not support screen.deviceXDPI / screen.logicalYDPI, so this code will not work in it.
96dpi | 120dpi | 144dpi |
---|---|---|
![]() | ![]() | ![]() |
Lyrical digression about screen.deviceXDPI, screen.logicalXDPI and Page zoom
In IE8, when the Full-page zoom is enabled, the value of screen.deviceXDPI changes. At 125% zoom it = 120, at 150% - 144. At 100% (without scaling) screen.deviceXDPI returns to 96. At the same time, it does not matter what dpi is in Windows.
That's what we need to check for (screen.deviceXDPI == screen.logicalXDPI)!
This is the case - when the user in the lower right corner of IE8, clicks on the select Page zoom and changes it.
But screen.logicalYDPI in 8-ke seems to be a constant number, in my tests it was always 96.
In the 7-ke and 6-ke, both of these values, with the tests, changed only depending on the settings of Windows. Page zoom in IE7 did not change the value of either one or the other property.
I accidentally discovered this a year after writing the article, when I wrote a crutch to an ancient site :)
By the way Page zoom in IE8 is better than in IE7:
IE7 Full-page zoom:
IE8 Full-page zoom (Adaptive Zoom):
The horizontal scroll now appears only if the columns have a fixed width, line breaks are inserted into new places (after scaling), in general it is very similar to how it happens in FF and Opera.
The mechanism is called Adaptive Zoom, more information about it can be found in the blog of developers IE 6 .
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 ); }
Curiously, this is a rare case of applying the css zoom property for its intended purpose, and not for the task of Layout.
min-resolution
property.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
is the choice of a non-existent element x with the -moz-any-link pseudo-class. Such a pseudo-class is understood only by Gecko-browsers, the rest will ignore the entire line 7 .
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}
The rule starting with body
will be ignored in Opera 9.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! */}
By the way, it’s not a fact that the user himself set 120dpi.
He could just buy a laptop, where such default settings are.
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! */}
#header { scrollbar-track-color:expression( this.runtimeStyle.scrollbarTrackColor = "#fff", ((screen.deviceXDPI/screen.logicalXDPI) == 1) ? (document.body.style.fontSize = 1/(screen.logicalYDPI/96) +'em') : false ); }
@media all and (min-resolution: 120dpi) { ... }
although on the docks, on the contrary, it is written that only in presto 2.5 there was support for it , but it was not there before (as then worked before?). I tried various options, googled, searched the Opera forum, but found nothing / did not help. Judging by the specs , everything was correct in my code. After discussing with pepelsbey , we came to the conclusion that this was a bug, a bug report was sent. Now it remains to wait until Opera fix. Fortunately, in the west, where the 120dpi problem is common, almost no Opera, and we, where Opera is popular, have almost no 120dpi problem :)Notes:
- Pavel Kornilov: Thin CSS for Internet Explorer (expression)
- MSDN: deviceYDPI Property
- MSDN: logicalYDPI Property
- MSDN: Adjusting Scale for Higher DPI Screens
- MSDN: Making the Web Bigger: DPI Scaling and Internet Explorer 8
- MSDN: Internet Explorer 8 and Adaptive Zoom
- According to the CSS2 specification, the browser must ignore the style if something unfamiliar is found in the selector.
- MSDN: About Conditional Comments
Learn more about what dpi is:
Source: https://habr.com/ru/post/42794/
All Articles