Computer >> Máy Tính >  >> Lập trình >> CSS

Tạo một hộp trong suốt với CSS

Để tạo một hộp trong suốt bằng CSS, bạn có thể thử chạy mã sau

Ví dụ

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            background-color: #808000;
            padding: 20px;
         }
         div.myopacity {
            opacity: 0.4;
            filter: alpha(opacity=80);
         }
      </style>
   </head>
   <body>
      <h1>Heading</h1>
      <p>Check trensparency in the below box:</p>
      <div class = "myopacity">
         <p>opacity 0.4</p>
      </div>
      <div>
         <p>opacity 1</p>
      </div>
   </body>
</html>