views:

242

answers:

2

Hello,

I have an element with a transparent png as its background image - it's like a polaroid with the photo bit cut out so just the frame is showing.

With this as the background I then want a standard image to sit behind the element that has the transparent png background - to fit inside the frame.

i've tried setting z-indexing and opacity and although I can get the image to show through its obviously transparent because of the opacity settings.

Any ideas?

+1  A: 

If .yourPhoto is a background image, you could do this:

<div class="yourPhoto">
    <div class="yourPNGframeImage">
    </div>
<div>

Or you could use inline images and position both absolute:

 <div class="container">
      <img class="yourPhoto" src="">
      <img class="yourPNGframeImage src="">
 </div>

.container {position: relative;}
.yourPhoto, .yourPNGframeImage {position: absolute; top: 0px; left: 0px;}
DA
I like this answer. I used a very similar concept on this page: http://www.screenfeed.com/content/. View the source related to the thumbnails.
jessegavin
This is what I've ended up doing.i just that it would perform better if the element with the transparent background sat infront of the image.
Meander365
@Meander365 that's exactly what the above two examples do. In both cases, the 'frame' is positioned on top of the photo.
DA
A: 

there is a fair few things to look out for when doing PNG.

  1. when cutting make sure you background is off.
  2. export as png24.
  3. if your in ie6 you will need to use someting like twin-helix png fix
  4. http://www.twinhelix.com/

Try these steps. You should not have to change the opacity of your image as it will affect the whole image. When you use z-indexing you should also put in the position css element

Kieran