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

JavaScript로 배경의 페인팅 영역을 설정하는 방법은 무엇입니까?


JavaScript로 배경의 페인팅 영역을 설정하려면 backgroundClip을 사용하세요. 재산. 다음 코드를 실행하여 배경의 페인팅 영역을 설정할 수 있습니다. -

예시

<!DOCTYPE html>
<html>
   <head>
      <style>
         #box {
            border: 2px dashed green;
            padding: 35px;
            width: 600px;
            height: 400px;
            background-color: blue;
            background-clip: border-box;
         }
      </style>
   </head>
   <body>
      <button onclick="display()">Set painting area</button>
      <div id="box">
         This is Demo Text! This is Demo Text! This is Demo Text!
         This is Demo Text! This is Demo Text!
      </div>
      <script>
         function display() {
            document.getElementById("box").style.backgroundClip = "content-box";
         }
      </script>
   </body>
</html>