background
|
|
RiscOS
Risc OS Info
All you need to know about Risc OS and more.
More icon

bonsai
The Element
A small area for Bonsai related material.
More icon
|
|
Up Image
Navigation
Search this Site
Enter your search terms

Site Breadcrumb - You are here
|
Reference   JavaScript Code Library

WM_scaleFont() scales the fonts on the page depending on the width of the window. It's very useful for creating a page that's designed to fit within a window without scrolling. For the whole effect to work well, use relative units (em, ex, %) for all your CSS positioning and for image and DIV sizes.

Usage: WM_scaleFont(targetSize, initialFontSize, fontUnits);

The targetSize is the window size for which you designed your page. The initialFontSize is the size you want for default text when the window is at the targetSize. The fontUnits are the units (pt or px) of your initial body tag.

All fonts that you wish to scale must be in a relative CSS unit (em, ex, %). This refers to their size relative to the default body font size. For example, if you've set the default font to be 40px and you specify some other text to be 50%, it will be 20px when the window is open to the targetSize and 10px when the window is open to half the targetSize.

The template comes configured for authoring at 640px wide. To change the intended authoring size, change the function calls that read: WM_scaleFont(640, 40, 'px'); to: WM_scaleFont(800, 40, 'px'); where the new size is the first argument (800, in this example).

Unfortunately, due to limitations in Dreamweaver, this cannot be released as an action at this time. It is being released as a template file. To install, follow the instructions below, and feel free to remove the example text.

Get the template file.

Instructions: Templates are stored in the Dreamweaver application folder, inside Configuration > Templates. Save the link above into this folder, and then open it from Dreamweaver's Help menu.