开发者

css image mask overlay

I'm trying to get a transparent png frame image to hover over an img tag to create the look of a frame over it. I've tried multiple different approaches and none seem to work.

The latest method I used was http://www.cssbakery.com/2009/06/background-image.html this doesn't seem to work either.

HTML

<div class="filler">
    <div class="filler-picture">
        <img src="../../media/img/test.jpg" alt="test" />
        <div class="filler-mask">&nbsp;</div>
    </div>
</div>

CSS

.filler {

    padding-left:20px;
    height:361px;
    width:559px;
    float:left;

}

.filler-mask {

    background: url('..img/filler.png') no-repeat;
    position: absolute;
    left:0; top:0;
    height:361px;
    width:559px;

}

.filler-picture {

    z-index: 0;
    background: url('..img/test.jpg') no-repeat;
    position: relative;
    height: 361px;
    width: 559px;
    display: block;

}

Does anyon开发者_Go百科e have any idea why this isn't working.


you could put 2 absolute divs under filler-picture with different z-index

<div class="filler">
    <div class="filler-picture">
        <div class="filler-img">
            <img src="../../media/img/test.jpg" alt="test" />
        </div>
        <div class="filler-mask">
            <img src="../../media/img/filler.png" alt="filler" />
        </div>
    </div>
</div>

CSS

.filler-mask {
    position: absolute;
    left:0; top:0;
    height:361px;
    width:559px;
    z-index: 900;
}

.filler-img{
    position: absolute;
    left:0; top:0;
    height:361px;
    width:559px;
    z-index: 50;
}

instead of using the image as a background you could put the image directly but images don't follow z-index so you have to wrap the images in divs.


Since the original question referenced a post on my blog, I decided to write an update to my Cookie Cutter Method using Neil's markup as an example.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜