Add transparency to the background with CSS

CSSWeb DevelopmentFront End Technology

Use the opacity property to add transparency to the background of an element. You can try to run the following code to work.

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            background-color: #808000;
            padding: 20px;
         }
         div.one {
            opacity: 0.2;
            filter: alpha(opacity=20);
         }
         div.two {
            opacity: 0.5;
            filter: alpha(opacity=50);
         }
      </style>
   </head>
   <body>
      <h1>Heading</h1>
      <p>Check transparency in the below section:</p>
      <div class = "one">
         <p>opacity 0.2</p>
      </div>
      <div class = "two">
         <p>opacity 0.5</p>
      </div>
      <div>
         <p>opacity 1</p>
      </div>
   </body>
</html>
raja
Published on 09-May-2018 08:53:49
Advertisements