Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Make Transparent Background Images Using CSS

    Khaled GarbayaKhaled Garbaya

    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.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    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.