Sams Teach Yourself HTML and CSS in 24 Hours (7th Edition)
You will see how to make your own background tiles later in this hour, but first a word about how to let the background show through parts of your foreground graphics. Web page images are always rectangular. However, the astute observer of Figure 9.2 (that's you) will notice that the background tiles show through portions of the title image, and therefore the title picture doesn't look rectangular at all. This works because portions of the image are transparent, which allows the background to show through. You'll often want to use partially transparent images to make graphics look good over any background color or background image tile. To make part of an image transparent, the image must be saved in the GIF or PNG file format. (JPEG images can't be made transparent.) Most graphics programs that support the GIF format allow you to specify one color to be transparent, whereas PNG images allow for a range of transparency. Largely because of this transparency range, the PNG format is superior to GIF. All the latest web browsers already support PNG images. For more information on the PNG image format, visit http://www.libpng.org/pub/png/pngintro.html. In the pond sample page in the preceding section, the title image was specified as a GIF with transparency. However, because GIF images allow only a single transparency color, the drop shadow doesn't quite work as desired. You'll quickly realize that GIF images with transparency often look good only with one type of background image or color. In this case, the pond title looked great on a white background but doesn't work so well on a tiled image background. The solution is to use a PNG image for the tiled background, which can support varying degrees of transparency, as opposed to a single color. Figure 9.4 shows the same web page with a PNG version of the same title image. Figure 9.4. The PNG version of the pond title image with improved transparency provides the desired drop-shadow effect regardless of the background.
The figure reveals how the drop shadow now allows some of the background image to filter through, which is the intended effect. This difference between GIF and PNG transparency may seem subtle but it can have a huge impact on the visual appeal of your pages.
Try It Yourself Follow these steps to save a transparent GIF in Paint Shop Pro:
|
Категории