With CSS add transparency to a button


To add transparency to a button, use the CSS opacity property. This creates a disabled look for the button.

You can try to run the following code to add transparency to a button

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         .btn1 {
            color: black;
            text-align: center;
            font-size: 15px;
         }
         .btn2 {
            color: black;
            text-align: center;
            font-size: 15px;
            opacity: 0.8;
         }
      </style>
   </head>
   <body>
      <h2>Result</h2>
      <p>Click below for result:</p>
      <button class = "btn1">Enabled</button>
      <button class = "btn2">Disabled</button>
   </body>
</html>

Updated on: 24-Jun-2020

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements