Resize this window. If you have javascript turned on, the text size in this column should resize. The header and navigation will not.
Here's a simple DOM scripting technique for sizing text content depending on the width of its containing element, or any other element for that matter, including the document body. This is useful if you want to:
Features include:
Nothing special here. Just create your accessible, semantically wonderful markup as usual.
Again, nothing very special is going on, but there are a few things you'll need to know:
The script works by taking the current display width of a reference element, and using that to determine the CSS font-size declaration for a target element, in percentage units. A ratio is set to determine how the font size is calculated. Text sizing takes place when the document loads and when the window is resized.
Additionally, optional minimum and maximum font size values for the target element can be supplied to make sure that the text doesn't get too small or stupidly big.
Follow these steps for text zoom happiness:
<script> tag to link to it.<script type="text/javascript">
var contentZoom = new TextZoom(
"Content", // Reference element
"Content", // Target element
0.22, // Zoom ratio
70, // Minimum font size (%)
130); // Maximum font size (%)
addLoadEvent(textZoomInit);
</script>
body element will be used.body element will be used.0.18 * 600 = 108%. Play around with ratio values for your layout.That's it.
Here's another example of the script in action using Matthew Levine's three column Holy Grail layout and a resizing image technique stolen from Richard Rutter, which seems to go rather well with this idea.
Tested on Win IE 5.0, 5.5 & 6; Win & OS X Firefox 1.5; OS X Safari 2; Win Opera 8.5. Other browser support information gratefully received.
Disclaimer: This is a work in progress. Also, my scripting skills are a bit haphazard, so if you have improvements, suggestions or abuse, please comment over here.