Simple Rounded Box
The box in the first example creates a simple expandable rounded box filled with a solid color, as shown in Figure 24-8.
Figure 24-8. Simple box with rounded corners
Tip
These separate images could be combined into a single image file and applied in varying positions to each corner of the box. The advantage is the need to load or preload only one image, as opposed to four. This technique is discussed in more detail in the upcoming "CSS Rollovers" section.
This technique takes four image files (one for each corner) and applies them as background images to four elements in the markup. Figure 24-9 shows each image file used in the example.
Figure 24-9. The corner graphics for the simple box
The trick is making sure that the markup has four available
elements for background image placement. This is what CSS designers
commonly refer to as finding hooks in the markup to
which styles can be applied. If your document structure has fewer than
four elements, it may be necessary to add a div
or two to get the necessary number of
hooks (see note below). This generic, all-purpose example is created
entirely out of div
s, but it is
preferable to use actual elements that have been marked up
semantically.
<div class="box"> <div class="top"> <div></div> </div> <div class="content"> <h1>Header</h1> ...
Get Web Design in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.