Positioning the <div> ElementsBecause the images and captions will sit beside each other in rows, you will need to float the <div>. This can be achieved using float: left. When the <div> is floated, it must be given a width. In this case, you will use width: 130px. This width can be changed to suit your needs. Next, you might want to create some space around the <div> elements so that they don't butt up against each other. You can achieve this by applying margins to the right and bottom of each <div>. Finally, a background image (shown in Figure 12.1) will be added to the <div>. As you can see in Figure 12.1, the image is very long so that it is able to grow to accommodate long captions. Figure 12.1. Screenshot of background image used by <div> element.
This background image must be set to no-repeat because you don't want it to reappear under the caption. The CSS code is shown in Listing 12.3 and illustrated in Figure 12.2. Listing 12.3. CSS Code Floating the Containerdiv.thumbnail
{
width: 130px;
float: left;
margin: 0 10px 10px 0;
background: url(chapter12a.gif) no-repeat;
}
Figure 12.2. Screenshot of positioned containers. |