The EWJ Database > When I'm Bored Script Series > Zooming Text and Pictures
|
Zooming Text and PicturesSo you have a big picture that you want to shrink down or a small picture that you want to enlarge? Why not use the built-in sizing? Maybe you want the text to increase in size with the picture. Sure you could calculate everything, and even get the font size to work nicely. But then you realize that you did a lot of work and your background looks the same. This zoom feature will enlarge or shrink anything you tell it to. If you tell it to zoom the entire page, even the scroll bar will increase in size. Although this is used like CSS, it is a Microsoft® extension through IE. In other words, this only works on IE. Zooming an Entire PageIf you want to enlarge your entire page (or make it smaller), you will need to use a stylesheet in your HTML document header. It should look something like the following:
This will double the size of the elements on the page. For more information on syntax, see the bottom of this article. Zooming an Element or ElementsMaybe you only want to zoom only a picture, or several paragraphs. To do so, enclose the HTML tags within these tags:
If you are not planning on adjusting the zoom with scripts, you do not need the "ID" part. This can be modified through scripts with "xxxx.style.cssText" with "xxxx" representing the ID or even document for zooming. Of course, other CSS changes can be made in the same way. SyntaxHere are all the possible values for the zoom.
If you use the zoom on a page, use it sparingly as large pictures may cause noticable increases in time required to render the page. A Cruel Trick: An ExampleDo you know someone who has a 21 inch (53.34 cm) monitor who refuses to set their resolution higher than 640x480? Why not say something about them and make it really hard to read! Let's say the person is named Bob. Here is our example for Bob: Before getting offended, scroll down.
A Zoom-Out button is provided so you can see the entire thing. Sure
this example is pointless, but the code reveals how the zoom works through
the use of scripts:
This example works as long as the font size is not set to the largest setting. |