CSS-배경 위치

기술

지정된 경우 요소 배경 이미지의 초기 위치를 설정합니다. 값은 일반적으로 쌍을 이루어 x, y 위치를 제공합니다. 기본 위치는 0 % 0 %입니다.

가능한 값

  • percent
  • none
  • length
  • top
  • center
  • bottom
  • left
  • right

적용

블록 수준 및 대체 요소

DOM 구문

object.style.backgroundPosition = "10 30";

다음은 배경 이미지 위치를 왼쪽에서 100 픽셀 떨어진 위치로 설정하는 방법을 보여주는 예입니다.

<table style = "background-image:url(/https/isolution.pro/images/pattern1.gif); background-position:100px;">
   <tr>
      <td>
         Background image positioned 100 pixels away from the left.
      </td>
   </tr>
</table>

다음은 배경 이미지 위치를 왼쪽에서 100 픽셀, 위쪽에서 200 픽셀 떨어진 곳에 설정하는 방법을 보여주는 예입니다.

<html>
   <head>
   </head>

   <body>
      <p style = "background-image:url(/https/isolution.pro/css/images/logo.png); background-position:100px 200px;">
         The background image positioned 100 pixels away from the 
         left and 200  pixels from the top.up
      </p>
   </body>
</html>

다음 결과가 생성됩니다-


Language