图片中央覆盖文字

来源:互联网 发布:sql统计男女生人数 编辑:程序博客网 时间:2024/04/28 04:38
/* CSS Document */

#blah {
height: 50px; /*圖片高度*/
width: 180px; /*圖片寬度*/
background-image: url(test.jpg); /*圖片位址*/
background-repeat:no-repeat;
text-align:center;
font-size:12px;
font-family:"宋体";
color:yellow; /*字体颜色*/
}

/*包裹显示文字的图层*/
#blah div {
    float:left;
    width: 100%;
    position: relative;
    top: 50%;
    margin-top: -0.5em;
}

/* HTML Document */
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="pictitle.css" rel="stylesheet" type="text/css" media="screen"/>
<title>无标题文档</title>
</head>

<body>
<div id="blah"><div>你要出现的字</div></div>
</body>
</html>