Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add hue to a regular image with CSS

Tags:

html

css

image

I have a regular image in the image tag like this:

<img src="http://i.imgur.com/StEW4JD.jpg" class="image">

that I want to turn into this image. I saw some examples of the blend mode but for the blend mode you need to set the image as background but I have the image in the image tag.

Can the hue be added to the image via css without setting image as background?

like image 835
user7592255 Avatar asked Feb 20 '17 10:02

user7592255


People also ask

How do I change the color of a PNG in CSS?

We can change the color of PNG image using following CSS styles: filter: none | blur() | brightness() | contrast() | drop-shadow() | grayscale() | hue-rotate() | invert() | opacity() | saturate() | sepia() | url() | initial | inherit; The above property is used to set the visual effect of the image.

How do I change my hue in CSS?

Use the hue-rotate() function to apply a hue rotation on an image. The CSS hue-rotate() function is used with the filter property to apply a hue rotation an image. A hue rotation is where you specify an angle around the color circle that the input samples will be adjusted by.

How do you change the color of an image to white in CSS?

If the product team was kind enough to also provide a white version of the image, you can simply toggle the image's src on hover. This can be done using JavaScript. You can use an onmouseover function that sets the image's src to white. png and then an onmouseleave function that sets the image's src to black.


2 Answers

Use a parent to your image with the desired background color.
Than set mix-blend-mode: overlay; to your image

img{max-width:100%;vertical-align:top;}


.blend-overlay{ mix-blend-mode: overlay; }
<div style="background:#822;">
   <img class="blend-overlay" src="https://i.imgur.com/StEW4JD.jpg">
</div>

https://stackoverflow.com/a/31528825/383904

like image 164
Roko C. Buljan Avatar answered Oct 09 '22 17:10

Roko C. Buljan


you looking this type image. Demo link here https://jsfiddle.net/JentiDabhi/9v96yfro/

HTML

<div class="image-box">
  <img src="http://i.imgur.com/StEW4JD.jpg" class="image">
</div>

CSS

.image-box {
    position: relative;
    display: inline-block;
}

div.image:after {
    content: "";
    background: rgba(255, 0, 0, 0.4);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
like image 2
Jenti Dabhi Avatar answered Oct 09 '22 19:10

Jenti Dabhi