스타일 왼쪽 속성
예시
<button> 요소의 왼쪽 위치를 설정합니다.
document.getElementById("myBtn").style.left = "100px";
정의 및 사용
left 속성은 배치된 요소의 왼쪽 위치를 설정하거나 반환합니다.
이 속성은 패딩, 스크롤바, 테두리 및 여백을 포함한 요소의 왼쪽 위치를 지정합니다.
팁: 위치 지정 요소는 위치 속성이 상대, 절대 또는 고정으로 설정된 요소입니다.
팁: 배치된 요소의 올바른 위치를 설정하거나 반환하려면 right 속성을 사용하십시오.
브라우저 지원
Property | |||||
---|---|---|---|---|---|
left | Yes | Yes | Yes | Yes | Yes |
통사론
왼쪽 속성을 반환합니다.
object.style.left
왼쪽 속성을 설정합니다.
object.style.left = "auto|length|%|initial|inherit"
속성 값
Value | Description |
---|---|
auto | Lets the browser set the left position. This is default |
length | Defines the left position in length units. Negative values are allowed |
% | Sets the left position in % of the width of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
기술적 세부 사항
기본값: | 자동 |
---|---|
반환 값: | 위치가 지정된 요소의 왼쪽 위치를 나타내는 문자열 |
CSS 버전 | CSS2 |
더 많은 예
예시
<div> 요소의 왼쪽 위치를 설정합니다.
document.getElementById("myDIV").style.left = "100px";
예시
음수 값 사용 - <div> 요소의 왼쪽 위치 설정:
document.getElementById("myDIV").style.left = "-100px";
예시
<div> 요소의 왼쪽 위치를 반환합니다.
alert(document.getElementById("myDiv").style.left);
관련 페이지
CSS 튜토리얼: CSS 포지셔닝
CSS 참조: 왼쪽 속성
❮ 스타일 개체