2016-10-03 43 views
1

我希望懸停時像這樣:從第一張圖片到第二張圖片。效果是:灰度模糊原始圖像+ 頂部的乘法層。如何在懸停時在圖像上添加多重混合模式的圖層?

From this

to this

現在我使用的變化到另一個圖像伎倆要做到這一點,但它的不方便。這裏是我到目前爲止的代碼:

.imgwrapper { 
 
    position: relative; 
 
} 
 
.showtext + div { 
 
    position: absolute; 
 
    left: 113px; 
 
    top: 113px; 
 
color: white; 
 
text-decoration:underline; 
 
    display: none; 
 
    pointer-events: none; 
 
    font-size: 18px; 
 
    width: 250px; 
 
    letter-spacing: 4px; 
 
} 
 
.showtext:hover + div { 
 
    display: block; 
 
}
<a href="single-illustration-sidebar-left.html" class="permalink"> 
 
\t \t \t \t \t <div class="desktop-3 mobile-half columns"> 
 
\t \t \t \t \t \t <div class="item"> 
 
\t \t \t \t \t \t \t <h3>Plython album</h3> 
 
\t \t \t \t \t \t \t <span class="category">identity</span> 
 

 
\t \t \t \t \t \t \t <div class="imgwrapper"> 
 
\t \t \t \t \t \t \t <img class="showtext" src="images/thumb_item08.png" onmouseover="this.src='images/thumb_item08a.png';" onmouseout="this.src='images/thumb_item08.png';" /> 
 
\t \t \t \t \t \t \t <div id="view">view</div></div> 
 
\t \t \t \t \t \t </div><!-- // .item --> 
 
\t \t \t \t \t </div><!-- // .desktop-3 --> 
 
\t \t \t \t </a>

謝謝!

回答

2

我希望你覺得這段代碼有用。

Working Fiddle

你需要添加一個容器你的形象,並引發懸停就可以了。

.img-con { 
 
    width: 250px; 
 
    padding: 5%; 
 
    background: rgba(209, 19, 15, 0); 
 
    transition: ease .1s; 
 
    -webkit-transition: ease .1s; 
 
    -moz-transition: ease .1s; 
 
    -ms-transition: ease .1s; 
 
    -o-transition: ease .1s; 
 
} 
 
.img-con > img { 
 
    position: relative; 
 
    width: 100%; 
 
    transition: ease .1s; 
 
    -webkit-transition: ease .1s; 
 
    -moz-transition: ease .1s; 
 
    -ms-transition: ease .1s; 
 
    -o-transition: ease .1s; 
 
} 
 
.img-con:hover { 
 
    background: rgba(209, 19, 15, 0.75); 
 
} 
 
.img-con:hover > img { 
 
    z-index: -1; 
 
    -webkit-filter: grayscale(100%) blur(2px) contrast(200%); 
 
    filter: grayscale(100%) blur(2px) contrast(200%); 
 
}
<div class="img-con"> 
 
    <img src="http://i.stack.imgur.com/zzzFU.png" /> 
 
</div>

+0

對不起已故的答覆,是的,它完美的作品!謝謝你 – Phuong

+0

我剛剛意識到紅色層不是繁殖。當我使用background-image和background-blend-mode:multiply;它變成了多元化,但在你的代碼中,圖像鏈接是在HTML中,所以我不知道如何使其倍增,有沒有辦法?謝謝 – Phuong

+1

我想通過使用混合混合模式,它現在就像我想要的那樣工作。 – Phuong

相關問題