Make Transparent Background Images Using CSS

Khaled Garbaya
InstructorKhaled Garbaya
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 4 years ago

In CSS, there is no property background-opacity, but you can fake it by inserting a pseudo-element with regular opacity. Using that trick you can create a watermark effect with few lines of CSS.

Khaled Garbaya: [0:00] Here, I have a div that contains an image. I would like to apply some watermarks on the bottom right in here, using my logo. To do that, let's first set the div position to relative.

[0:22] Then we go to the div after selector. We set the content to be empty. We can give it a width of 80 pixel, and a height of 80 pixel. That's the height of my logo. Now, we can apply a background.

[0:48] This will be the URL image of my watermark logo. We set it to no-repeat. After that, we need to set the position to absolute.

[1:03] You can see the logo is over here. Now, we set the bottom to zero, and the right to zero. Now, we want to set some transparency for the logo. For that, we can do opacity, .3. That's how you do a watermark effect using CSS.