CSS中的重叠图像
如何让“mymessage.gif”显示在“bread\u wine.jpg”上 mymessage.gif具有透明的背景CSS中的重叠图像,css,Css,如何让“mymessage.gif”显示在“bread\u 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"> <!-- #na
<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>
重叠图像
这是导航栏
试试看
现在,图像已经重叠了。您无法看到它,因为您没有将大小添加到此分区。请尝试以下操作:
#overlapthis {
background-image: url(mymessage.gif);
width: 500px;
height: 100px;
}
然后添加边距(和一个位置:绝对)以将图像定位到所需位置。效果非常好!非常感谢你!不用担心,伙计,随时都可以。希望你能理解那里发生了什么:)
背景尺寸:80px×px
可以用来指定图像的大小。在我的例子中,z-index是一个重要的参数。谢谢
#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;
}
#overlapthis {
background-image: url(mymessage.gif);
width: 500px;
height: 100px;
}