Pro HTML5 and CSS3 Design Patterns

(avery) #1

CHAPTER 14 ■ IMAGES


Content over Background Image


HTML


<h1>Content over Background Image</h1>
<div id="crater-lake">
<h3 class="caption">Crater Lake North Rim</h3>
<p id="crater-date"><img src="star.gif" alt="" /> August 4, 2003
<img src="star.gif" alt="" /></p></div>

CSS


#crater-lake { position:relative; padding:0; width:700px; height:500px;
background:black url("crater-lake.jpg") no-repeat center center; }

#crater-lake .caption { position:absolute; margin:15px; left:0; top:0;
font-size:1.05em; color:white; }

#crater-date { position:absolute; left:0; bottom:10px; width:700px;
text-align:center; color:white; font-size:0.8em; }

/* Nonessential rules are not shown. */
Free download pdf