padding-top
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
시도해보기
padding-top: 1em;
padding-top: 10%;
padding-top: 20px;
padding-top: 1ch;
padding-top: 0;
<section id="default-example">
<div class="transition-all" id="example-element">
<div class="box">
Far out in the uncharted backwaters of the unfashionable end of the
western spiral arm of the Galaxy lies a small unregarded yellow sun.
</div>
</div>
</section>
#example-element {
border: 10px solid #ffc129;
overflow: hidden;
text-align: left;
}
.box {
border: dashed 1px;
}
요소의 안쪽 여백 영역은 콘텐츠와 테두리 사이의 공간입니다.
참고:
padding
속성을 사용하면 하나의 선언으로 네 방향 여백을 모두 설정할 수 있습니다.
구문
css
/* <length> 값 */
padding-top: 0.5em;
padding-top: 0;
padding-top: 2cm;
/* <percentage> 값 */
padding-top: 10%;
/* 전역 값 */
padding-top: inherit;
padding-top: initial;
padding-top: unset;
padding-top
속성의 값은 아래 목록 중 하나로 지정할 수 있습니다. 바깥 여백margin과 다르게, 음수 값은 사용할 수 없습니다.
값
<length>
-
여백의 크기로 고정값 사용.
<percentage>
-
여백의 크기로 컨테이닝 블록 너비의 백분율 사용.
형식 구문
padding-top =
<length-percentage [0,∞]>
<length-percentage> =
<length> |
<percentage>
예제
css
.content {
padding-top: 5%;
}
.sidebox {
padding-top: 10px;
}
명세
Specification |
---|
CSS Box Model Module Level 3 # padding-physical |
초기값 | 0 |
---|---|
적용대상 | all elements, except table-row-group , table-header-group , table-footer-group , table-row , table-column-group and table-column . It also applies to ::first-letter and ::first-line . |
상속 | no |
Percentages | refer to the width of the containing block |
계산 값 | the percentage as specified or the absolute length |
Animation type | a CSS data type are interpolated as real, floating-point numbers.">length |
브라우저 호환성
BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.