简体   繁体   English

带有CSS的悬停颜色叠加-.png图像

[英]Colour overlay on hover with css - .png image

I'm trying to create a colour overlay on hover effect for my website. 我正在尝试为我的网站在悬停效果上创建颜色覆盖。 I'm displaying clients/customers. 我正在显示客户/客户。 (like so: http://www.squarespace.com/customers/ ) - but I'd like to change it specifically to a blue overlay, not reduce the images opacity. (例如: http : //www.squarespace.com/customers/ )-但我想将其专门更改为蓝色叠加层,而不是降低图像的不透明度。

Here's where I've got thus far 这是我到目前为止所到之处

https://jsfiddle.net/gavinfriel/d98sv4cy/ https://jsfiddle.net/gavinfriel/d98sv4cy/

I'm wondering is there an easy way to do this with css - like using a colour mask so that covers the png logo only. 我想知道是否有一种简单的方法可以使用CSS执行此操作-就像使用颜色遮罩一样,只覆盖png徽标。 I've been reading about the overflow: hidden; 我一直在阅读有关overflow: hidden; property but am not sure how to implement it. 属性,但不确定如何实现。

Your help would be appreciated, and I sincerely hope this is possible!! 您的帮助将不胜感激,我衷心希望这是可能的! (Thank you to those who have answered already) (谢谢那些已经回答的人)

I'm developing the website using Squarespace to css solutions would be appreciated as opposed to jquery/javascript. 我正在开发使用Squarespace的CSS解决方案的网站,而不是jquery / javascript。

I'd use transitions, they are widely supported now. 我会使用过渡,现在已经广泛支持它们。 This is based on the code you've provided: 这基于您提供的代码:

.icon div:hover {
    opacity: .5;
    transition: opacity .5s ease-out;
    -moz-transition: opacity .5s ease-out;
    -webkit-transition: opacity .5s ease-out;
    -o-transition: opacity .5s ease-out;
}

this should do the trick, use opacity and transition https://jsfiddle.net/d98sv4cy/1/ 这应该可以解决问题,使用不透明度并过渡https://jsfiddle.net/d98sv4cy/1/

.icon:hover {
    opacity: .33;
    transition-property: opacity;
    transition-duration: .2s;
    transition-timing-function: ease-in-out;
}

CSS混合模式是否值得考虑?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM