Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS로 배경에 투명도 추가

<시간/>

불투명도 사용 요소의 배경에 투명도를 추가하는 속성입니다. 다음 코드를 실행하여 작동할 수 있습니다.

예시

<!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>