如何让“mymessage.gif”显示在“bread_wine.jpg”上。
mymessage.gif具有透明背景。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>overlap images</title>
<style type="text/css">
<!--
#navbar {
font-size: 18px;
font-weight: bold;
text-align: center;
}
#thebigimage {
background-image: url(bread_wine.jpg);
height: 548px;
width: 731px;
margin-right: auto;
margin-left: auto;
}
#overlapthis {
background-image: url(mymessage.gif);
}
-->
</style>
</head>
<body>
<div id="navbar">this is the nav bar</div>
<div id="thebigimage">
<div id="overlapthis"></div>
</div>
</body>
</html>
答案 0 :(得分:14)
#overlapthis {
background-image:url("mymessage.gif");
height:100px;
left:50px; /* play around with this */
position:absolute;
top:90px; /* and play around with this */
width:500px;
}
#thebigimage {
background-image:url("bread_wine.jpg");
height:548px;
margin-left:auto;
margin-right:auto;
position:relative; /* and this has to be relative */
width:731px;
}
答案 1 :(得分:2)
尝试
#overlapthis {
position: absolute;
top: ??px;
left: ??px;
z-index: 1;
}
答案 2 :(得分:0)
如你所知,图像已经重叠。您无法看到它,因为您没有为您的重叠div添加大小。试试这个:
#overlapthis {
background-image: url(mymessage.gif);
width: 500px;
height: 100px;
}
然后添加边距(和位置:绝对)以将图像定位在所需位置。