How to correctly use the filter property in png CSS3 images

3

I already know that this could be done with other programs, but it has caused me curiosity in CSS. As you will see, img-amarillo has the same filter as img2-amarillo , however in the first one it does not change color and in the second one, why does this happen? (the values I put in the filter is the HSL of the yellow color)

#img
{background-image: url(http://pluspng.com/img-png/vector-icon-png-free-vector-icons-in-svg-psd-png-eps-format-or-as-icon-font-thousands-of-free-icons-in-the-largest-database-of-free-vector-icons-812.png);
width: 200px;
height: 200px;
background-repeat: no-repeat;
background-size: contain;
background-position: center
}
#img-amarillo
{background-image: url(http://pluspng.com/img-png/vector-icon-png-free-vector-icons-in-svg-psd-png-eps-format-or-as-icon-font-thousands-of-free-icons-in-the-largest-database-of-free-vector-icons-812.png);
width: 200px;
height: 200px;
filter: hue-rotate(60deg) brightness(500%) saturate(100%);
background-repeat: no-repeat;
background-size: contain;
background-position: center
}
#img2
{background-image: url(https://i.stack.imgur.com/fXKdt.png);
width: 200px;
height: 200px;
background-repeat: no-repeat;
background-size: contain;
background-position: center
}
#img2-amarillo
{background-image: url(https://i.stack.imgur.com/fXKdt.png);
width: 200px;
height: 200px;
filter: hue-rotate(60deg) brightness(500%) saturate(100%);
background-repeat: no-repeat;
background-size: contain;
background-position: center
}
<div id="img"></div>
<div id="img-amarillo"></div>
<div id="img2"></div>
<div id="img2-amarillo"></div>

'

    
asked by Orlando Pasaca Rojas 27.02.2018 в 16:46
source

1 answer

5

The problem you suffer is because the pure white and black colors have not defined the hue (it can be any), so the rotation does not affect them.

Multiplying by 5 the brightness of the black (500%) has no effect either (0 x 5 = 0).

In the second image it works because the red (0º) when turning it 60º gives yellow:

    
answered by 27.02.2018 / 16:56
source