css图像蒙版叠加

Nei*_*man 3 html css xhtml overlay

我正在尝试将透明的png帧图像悬停在img标记上,以在其上创建帧的外观.我尝试了多种不同的方法,但似乎都没有.

我使用的最新方法是http://www.cssbakery.com/2009/06/background-image.html这似乎也不起作用.

HTML

<div class="filler">
    <div class="filler-picture">
        <img src="../../media/img/test.jpg" alt="test" />
        <div class="filler-mask">&nbsp;</div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

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;

}
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么这不起作用.

rob*_*nal 5

你可以将2个绝对div放在不同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>
Run Code Online (Sandbox Code Playgroud)

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;
}
Run Code Online (Sandbox Code Playgroud)

而不是使用图像作为背景,你可以直接放置图像,但图像不遵循z-index,所以你必须将图像包装在div中.