tags:

views:

30

answers:

5

How do I get "mymessage.gif" to show over "bread_wine.jpg".

mymessage.gif has a transparent background.

<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>

Here is an external link: http://markparish.net/testing/testpage.htm

A: 

Try

#overlapthis {
    position: absolute;
    top: ??px;
    left: ??px;
    z-index: 1;
}
Jakub Konecki
A: 

What you need to do is set the position. See here for more info: http://www.w3schools.com/css/css_positioning.asp

Tim Čas
+2  A: 
#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;
} 
Claudiu
Worked perfectly! Thank You so much!
MP123
No worries buddy, anytime. Hope you understand what happens there :)
Claudiu
A: 

As you have it right now, the image overlaps already. You just can't see it because you didn't add sizes to your overlapthis div. Try this:

#overlapthis {
    background-image: url(mymessage.gif);
    width: 500px;
    height: 100px;
}

Then add margins (and an position: absolute) to position the image at your desired location.

Skunk