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

CSS에서 background-attachment 속성 사용

<시간/>

백그라운드 첨부 파일 t 속성은 배경에서 이미지의 스크롤을 제어하는 ​​데 사용됩니다.

예시

다음 코드를 실행하여 background-attachmen 작업 방법을 배울 수 있습니다. t 속성:

<!DOCTYPE html>
<html>
   <head>
      <style>
         body {
            background-image: url('/css/images/css.jpg');
            background-repeat: no-repeat;
            background-attachment: fixed;
         }
      </style>
   </head>
   <body>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
   </body>
</html>