margin-top
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
* Some parts of this feature may have varying levels of support.
margin-top CSS 속성은 요소의 위쪽에 바깥 여백 영역margin area을 설정합니다. 양수 값은 인접 요소와 거리를 넓히고, 음수 값은 더 좁힙니다.
시도해 보기
margin-top: 1em; margin-top: 10%; margin-top: 10px; margin-top: 0; <section id="default-example"> <div id="container"> <div class="row"></div> <div class="row transition-all" id="example-element"></div> <div class="row"></div> </div> </section> #container { width: 300px; height: 200px; display: flex; align-content: flex-start; flex-direction: column; justify-content: flex-start; } .row { height: 33.33%; display: inline-block; border: solid #ce7777 10px; background-color: #2b3a55; flex-shrink: 0; } #example-element { border: solid 10px #ffbf00; background-color: #2b3a55; } 구문
css
/* <length> 값 */ margin-top: 10px; /* 절대 길이 */ margin-top: 1em; /* 글씨 크기에 상대적 */ margin-top: 5%; /* 가장 가까운 블록 컨테이너의 너비에 상대적 */ /* 키워드 값 */ margin-top: auto; /* 전역 값 */ margin-top: inherit; margin-top: initial; margin-top: unset; margin-top 속성은 키워드 auto, <length>, <percentage>를 사용해 설정할 수 있습니다. 값은 양수, 0, 음수가 가능합니다.
값
<length>-
바깥 여백 크기의 고정 값.
<percentage>-
바깥 여백 크기와 블록 컨테이너 너비의 비율.
auto-
브라우저가 적절한 값 선택.
margin을 참고하세요.
형식 구문
margin-top =
<length-percentage> |
auto |
<anchor-size()>
<length-percentage> =
<length> |
<percentage>
<anchor-size()> =
anchor-size( [ <anchor-name> || <anchor-size> ]? , <length-percentage>? )
<anchor-name> =
<dashed-ident>
<anchor-size> =
width |
height |
block |
inline |
self-block |
self-inline
예제
css
.content { margin-top: 5%; } .sidebox { margin-top: 10px; } .logo { margin-top: -5px; } #footer { margin-top: 1em; } 명세
| Specification |
|---|
| CSS Box Model Module Level 3> # margin-physical> |
| 초기값 | 0 |
|---|---|
| 적용대상 | all elements, except elements with table display types other than table-caption, table and inline-table. It also applies to ::first-letter. |
| 상속 | no |
| Percentages | refer to the width of the containing block |
| 계산 값 | the percentage as specified or the absolute length |
| Animation type | a length |
브라우저 호환성
Loading…