ORIGINAL SOURCE: CSS Image Effects
In this short CSS tutorial I will show you how to create some really cool and easy CSS image effects that you can apply to any online image. The image effects I will show you are the most common photo effects that photographers use when developing a photo.
The CSS image effects I will demonstrate are:
- Old Paper Overlay
- Black and White
- Sepia
- Warm Colors
- Cold Colors
- Green Tint
- Magenta Tint
Though you can use tools like Photoshop, Lightroom or online tools like MockoFun and their awesome vintage photo editor to edit your photos, if you only need to place an image in a web page and apply a filter, here’s how to create cool CSS image effects.
CSS Image Effects using CSS filter
The filter CSS property is a very useful tool when you need to make image adjustments like adjusting the contrast, brightness, saturation etc of images in a web page.
Here’s a list of values that you can use with filter in CSS:
-
blur
for adding blur to images -
brightness
for making the image brighter or darker -
contrast
adjust the contrast of an image -
drop-shadow
use as an alternative to box-shadow -
grayscale
for transforming your image to gray scale -
hue-rotate
adjust hue values for your photo -
invert
inverts the colors of the image -
opacity
alter the transparency of the image -
saturate
alter the saturation values of your image -
sepia
apply a sepia effect to the image
These CSS filters take in values (either percent or pixels in the case of blur for example). Also, you can apply combinations of these filters to the same image element (or any other HTML element for that matter).
So, let’s see the CSS filter property in action!
Starting Image
Let’s apply some cool CSS image effects on it using various values of the filter property.
To create a more vintage effect we’ll also use this old texture from Vintage Paper Textures free pack by PhotoshopSupply. You can also check out this old paper background collection of over 150 different vintage textures or this huge collection of free textures.
CSS Image Effects: Vintage Overlay
HTML Code:
<div class="old-paper">
<img class="original-image" src="https://i.imgur.com/ouDwClz.jpg" />
<div class="overlay">
<img src="https://i.imgur.com/4rKVgAQ.png">
</div>
</div>
CSS Code:
.old-paper{
position:relative;
max-width:850px;
}
.original-image{
width:100%;
height:100%;
display:inline-block;
}
.overlay{
mix-blend-mode:multiply;
position:absolute;
display:inline-block;
left:0;
top:0;
right:0;
bottom:0;
}
.overlay img{
width:100%;
height:100%;
}
CSS Image Effects: Black and White
HTML Code:
<div class="old-paper">
<img class="original-image black-and-white" src="https://i.imgur.com/ouDwClz.jpg" />
<div class="overlay">
<img src="https://i.imgur.com/4rKVgAQ.png">
</div>
</div>
CSS Code:
.black-and-white{
filter:brightness(70%) contrast(150%) saturate(0%) brightness(150%);
}
CSS Image Effects: Sepia
HTML Code:
<div class="old-paper">
<img class="original-image sepia" src="https://i.imgur.com/ouDwClz.jpg" />
<div class="overlay">
<img src="https://i.imgur.com/4rKVgAQ.png">
</div>
</div>
CSS Code:
.sepia{
filter:filter:saturate(0%) sepia(100%) contrast(150%) saturate(150%);
}
CSS Image Effects: Warm Colors
HTML Code:
<div class="old-paper">
<img class="original-image warm" src="https://i.imgur.com/ouDwClz.jpg" />
<div class="overlay">
<img src="https://i.imgur.com/4rKVgAQ.png">
</div>
</div>
CSS Code:
.sepia{
filter: sepia(50%) contrast(150%) saturate(200%) brightness(100%) hue-rotate(-15deg);
}
NOTE: hue-rotate
shifts the hue of all the colors in the image. But why is the value in degrees?
Imagine the color wheel (actually, don’t imagine it, here it is)
Using hue-rotate
you can push one color by x degrees on the color wheel. 360 degrees will make a complete rotation, which will mean no change at all. The value for this property also works in the negatives and -90 for example is the equivalent of 270.
CSS Image Effects: Cold Colors
HTML Code:
<div class="old-paper">
<img class="original-image cold" src="https://i.imgur.com/ouDwClz.jpg" />
<div class="overlay">
<img src="https://i.imgur.com/4rKVgAQ.png">
</div>
</div>
CSS Code:
.cold{
filter: hue-rotate(180deg) sepia(75%) contrast(150%) saturate(300%) hue-rotate(180deg);
}
CSS Image Effects: Green Color Tint
HTML Code:
<div class="old-paper">
<img class="original-image tint-green" src="https://i.imgur.com/ouDwClz.jpg" />
<div class="overlay">
<img src="https://i.imgur.com/4rKVgAQ.png">
</div>
</div>
CSS Code:
.tint-green{
filter: hue-rotate(-30deg) sepia(75%) contrast(150%) saturate(300%) hue-rotate(30deg);
}
CSS Image Effects: Magenta Color Tint
HTML Code:
<div class="old-paper">
<img class="original-image tint-magenta" src="https://i.imgur.com/ouDwClz.jpg" />
<div class="overlay">
<img src="https://i.imgur.com/4rKVgAQ.png">
</div>
</div>
CSS Code:
.tint-magenta{
filter: hue-rotate(-270deg) sepia(55%) contrast(150%) saturate(300%) hue-rotate(270deg);
}
NOTE: One disadvantage of using images with CSS effects is that Google does not see the image with the applied effect. For the purpose of this tutorial, the images below are screenshots of the CSS image effects applied to the original image. They are NOT the live CSS effect. If you want to see or play around with the live effects please check this CodePen:
Credits
Old Texture image provided by PhotoshopSupply.com
Top comments (1)
To create stunning vintage photos using CSS, consider these 7 effects: sepia filter for a warm, brownish tone; grayscale filter to emulate black-and-white photography; blur effect to soften images and mimic old lenses; contrast adjustment to highlight features; brightness reduction to give a faded look; hue-rotation to shift colors; and vignette effect to darken edges. Each of these effects can be combined or adjusted to achieve the desired vintage aesthetic. In comparison, using Lightroom vs Photoshop for vintage effects offers more advanced and precise control over edits, with Lightroom excelling in batch processing and non-destructive editing, while Photoshop provides powerful tools for detailed image manipulation.