日期:2014-05-17  浏览次数:20698 次

CSS 文字替代图片下载失败情况
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" > 
 <head><title>Text Replacement</title>
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
  <link rel="stylesheet" href="site.css"   media="all"    type="text/css" />
  <link rel="stylesheet" href="page.css"   media="all"    type="text/css" />
 </head>
 
 <body>
 
 <h1>Text Replacement</h1>
 <h2 id="h2" >Heading ddd2<span></span></h2>

 </body>
</html>

?

CSS:

?

#h2 {
??? position: relative;
??? width: 250px;
??? height: 76px;
??? overflow: hidden;
}
/*
?* span里面的图片和h2中字的长宽一样,如果当图片显示不出来时候,自然就是字来充当
?*/
#h2 span {
??? position: absolute;
??? width: 250px;
??? height: 76px;
??? left: 0;
??? top: 0;
??? background: url("heading2.jpg") no-repeat;
}

?