CSS margin-left 속성
예시
<p> 요소의 왼쪽 여백을 30픽셀로 설정합니다.
p.ex1 {
margin-left: 30px;
}
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
속성 은 margin-left
요소의 왼쪽 여백을 설정합니다.
참고: 음수 값이 허용됩니다.
기본값: | 0 |
---|---|
상속: | 아니요 |
애니메이션 가능: | 예, 개별 속성을 참조하십시오 . 애니메이션 가능 에 대해 읽기 |
버전: | CSS1 |
자바스크립트 구문: | 개체 .style.marginLeft="100px" |
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
margin-left | 1.0 | 6.0 | 1.0 | 1.0 | 3.5 |
CSS 구문
margin-left: length|auto|initial|inherit;
속성 값
Value | Description | Play it |
---|---|---|
length | Specifies a fixed left margin in px, pt, cm, etc. Default value is 0px. Negative values are allowed. Read about length units | |
% | Specifies a left margin in percent of the width of the containing element | |
auto | The browser calculates a left margin | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
더 많은 예
예시
<p> 요소의 왼쪽 여백을 컨테이너 너비의 10%로 설정합니다.
p.ex1 {
margin-left: 10%;
}
예시
<p> 요소의 왼쪽 여백을 2em으로 설정합니다.
p.ex1 {
margin-left: 2em;
}
관련 페이지
CSS 튜토리얼: CSS 여백
HTML DOM 참조: marginLeft 속성