CSS Opacity / Transparency

CSSWeb DevelopmentFront End Technology

For CSS Opacity/ Transparency, the opacity property is used. For example,

opacity: 0.3;

Following is the code showing Opacity/ Transparency using CSS −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
body {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}
div {
   width: 200px;
   height: 200px;
   background-color: rgb(0, 0, 255);
   color: white;
   display: inline-block;
}
.transparent {
   background-color: rgba(0, 0, 255, 0.582);
}
img{
   width: 200px;
   height: 200px;
}
.transparent-img{
   opacity: 0.3;
}
</style>
</head>
<body>
<h1>Tansparency/Opacity Example</h1>
<div class="transparent">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Hic, accusantium.
</div>
<div>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum, nisi!
</div>
<hr>
<img src="https://i.picsum.photos/id/487/300/300.jpg">
<img class="transparent-img" src="https://i.picsum.photos/id/487/300/300.jpg">
</body>
</html>

Output

The above code will produce the following output −

raja
Published on 07-May-2020 10:30:42
Advertisements