스타일 objectPosition 속성
예시
콘텐츠 상자에 맞게 이미지 크기를 조정하고 콘텐츠 상자 내부에서 왼쪽에서 5px, 위쪽에서 10% 위치에 이미지를 배치합니다.
document.getElementById("myImg").style.objectPosition = "0 10%";
정의 및 사용
objectPosition 속성은 <img> 또는 <video>가 자체 콘텐츠 상자에 배치되어야 하는 방법을 지정하는 데 사용됩니다.
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
objectPosition | 31.0 | 16.0 | 36.0 | 10.1 | 19.0 |
통사론
objectPosition 속성을 반환합니다.
object.style.objectPosition
objectPosition 속성을 설정합니다.
object.style.objectPosition = "position|initial|inherit"
속성 값
Value | Description |
---|---|
position | Specifies the position of the image or video inside its content box. First value controls the x-asis and the second value controls the y-axis. Can be a string (left, center or right), or a number (in px or %). Negative values are allowed |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
기술적 세부 사항
기본값: | 50% 50% |
---|---|
반환 값: | 내용 상자에서 요소의 위치를 나타내는 문자열 또는 숫자 |
CSS 버전 | CSS3 |
관련 페이지
CSS 튜토리얼: CSS 객체 맞춤
CSS 참조: 개체 위치 속성
❮ 스타일 개체