|
Uncle Jim's Web Designs and Tutorials Writing for Multiple Resolutions Site Design Optimization Recommendations Author: Jim Stiles |
|
Fonts, Graphics and Layers Size Matters Fonts, graphics and layers are the three main elements that will need to be resized with different resolutions. It is possible to resize fonts by utilizing the DOM's new getElementById. You can also dynamically change the font size depending on the screen resolution using CSS and Javascript. By placing the following JavaScript at the end of your page: The Importance of Scalable Fonts More and more people are using high resolution monitors these days. As of writing, 74% of visitors to this site use 1024x768 resolution, while only 17% are using 800x600 resolution. As the number of people using 800x600 declines, the number of people using resolutions of 1024x768 and above is increasing. So what does this mean for web fonts?
Writing in Links to External CSS Files Lets assume we have three separate CSS style sheets, one for small fonts, one for medium fonts, and finally one for high fonts. If a font size is 9pt in the small font file, it could be 12pt in the medium, and 15pt in the high font file. We then check the screen resolution of the visitor's monitor, and write in the predefined CSS file through this JavaScript placed in the document header: This is a good example of using multiple if-blocks and logical operators such as less-than (<), greater-than (>) and AND (&&). While this is an effective method, it does have some problems. If you change one font definition you have to change this in the three separate CSS files. Also, the font sizes are not truly scalable, as there are only three available font sizes for each font used on the site. Calculate and Dynamically Write the font size in the CSS Class Here is an example of this solution: The key line in this example is the actual formula that calculates the font size:
The CSS classes containing these new font sizes are then written in (mainFont in the above example). Realistically you would have this script in a separate JavaScript (.js) file which can be accessed from every page throughout your site. Of the two solutions, I believe this one to be the best as it only requires one file to modify, not three, while the fonts are truly scalable. An Ending for Fonts Designing web sites that have fonts that react to the user's environment is not very difficult and is a requirement for any professional designer. If a user visits your site and is unable to actually read the text on the screen, then your design has failed.
|
|