Forum Moderators: not2easy
<div style="height:120px; width:120px;background-image:url(transparent.gif)">
<img src="real.gif" height="120" width="120" />
</div>
you need to take the image out of that div and instead have them one after the other, then move the div containing the transparent image back over the top of the real image. If you simply use a negative margin, the browsers will handle it differently so you also need to specify a new stacking context and this is done by using position relative and a z-index.
e.g.
CSS:
.overlay {
height:120px;
width:120px;
background: url(transparent.gif);
margin-top: -120px;
position: relative;
z-index: 1;
}HTML:
<img src="real.gif" height="120" width="120" />
<div class="overlay"> </div>
You should use the negative margin rather than the top co-ordinate or else the nature of relative positioning will leave a space where the div containing the transparent image would be in the normal flow.
let us know if that works for you
Suzy
Both IE and Moz support proprietry alpha transparency CSS rules that can be applied to ANY element, not just images:
.halftransparent {
filter: alpha( opacity=50);
-moz-opacity: .5;
}
As for not right clicking on the image, try adding onContextMenu='return false;' to your IMG tag.
Regarding your right-click protection, I like most other Firefox users I know turn this off (Tools / Options / Content / Advanced / Disable or replace content menus).
[edited by: Robin_reala at 12:57 pm (utc) on April 5, 2007]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<header>
<style type="text/css">
span.container{position:relative} /* or if you want to position it absolutely on your page, that's fine. We just need to set it to something other than it's default so it can be a proper container */
span.container img{vertical-align:top}
span.container img.overlap{position:absolute;left:0;top:0;z-index:whatever;}
</style>
</header>
<body>
<span class="container">
<img src="img1">
<img src="img2" class="overlap">
</span>
</body>
</html>
I don't really know why the vertical-align:top needs to be there, but it won't overlap 100% on at least one browser if you don't have it (firefox 1.5011)
This method is nice because it actually positions two elements exactly on top of eachother, while you can still keep normal flow of things that follow, and still make use of margins, or whatever else.
If you don't care about the space the images take up in the flow, you can position them both absolutely, but then since the container has no content, it's size becomes zero, and your page flow breaks (which won't matter if you're absolute positioning the container or something)
[edited by: Xapti at 11:16 pm (utc) on April 6, 2007]