Languages
[Edit]
EN

CSS - create transparent image

0 points
Created by:
Eshaal-Wilkinson
384

In this article, we would like to show you how to create a transparent image using CSS.

Quick solution:

.transparent {
  opacity: 50%;  /* opacity: 0.5; */
}

 

Practical example

In this example, we create three styles, three stages of the transparent image using opacity property and we assign the styles to the img elements using class selector (.class).

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>
    
    body {
      display: flex;
    }
    
    img {
      height: 100px;
      margin: 5px;
    }

    .transparent1 {
      opacity: 20%;  /* opacity: 0.2; */
    }

    .transparent2 {
      opacity: 50%;  /* opacity: 0.5; */
    }

    .transparent3 {
      opacity: 90%;  /* opacity: 0.9; */
    }

  </style>
</head>
<body>
  <img class="transparent1" src="https://dirask.com/static/bucket/1631898942509-VMYrnXyYZv--image.png" />
  <img class="transparent2" src="https://dirask.com/static/bucket/1631898942509-VMYrnXyYZv--image.png" />
  <img class="transparent3" src="https://dirask.com/static/bucket/1631898942509-VMYrnXyYZv--image.png" />
</body>
</html>
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join