Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

สร้างกล่องโปร่งใสด้วย CSS


คุณสมบัติ opacity

ใช้ opacity (0 ถึง 1) เพื่อทำให้องค์ประกอบโปร่งใส รวมทั้งเนื้อหาภายใน

ตัวอย่าง

<!DOCTYPE html>
<html>
<head>
  <style>
    div {
      background-color: #808000;
      padding: 20px;
    }
    div.myopacity {
      opacity: 0.4;
      filter: alpha(opacity=80); /* IE8 และก่อนหน้า */
    }
  </style>
</head>
<body>
  <h1>Heading</h1>
  <p>Check transparency in the below box:</p>
  <div class="myopacity">
    <p>opacity 0.4</p>
  </div>
  <div>
    <p>opacity 1</p>
  </div>
</body>
</html>