--- title: vertical-align slug: Web/CSS/vertical-align tags: - CSS - CSS Property - Reference translation_of: Web/CSS/vertical-align ---
vertical-align
CSS 속성은 inline 또는 table-cell box에서의 수직 정렬을 지정합니다.
/* keyword values */ vertical-align: baseline; vertical-align: sub; vertical-align: super; vertical-align: text-top; vertical-align: text-bottom; vertical-align: middle; vertical-align: top; vertical-align: bottom; /* <length> values */ vertical-align: 10em; vertical-align: 4px; /* <percentage> values */ vertical-align: 20%; /* Global values */ vertical-align: inherit; vertical-align: initial; vertical-align: unset;
vertical-align 속성은 두 컨텍스트에서 사용될 수 있습니다:
<p> top:<img style="vertical-align:top" src="https://mdn.mozillademos.org/files/15189/star.png"/> middle:<img style="vertical-align:middle" src="https://mdn.mozillademos.org/files/15189/star.png"/> bottom:<img style="vertical-align:bottom" src="https://mdn.mozillademos.org/files/15189/star.png"/> super:<img style="vertical-align:super" src="https://mdn.mozillademos.org/files/15189/star.png"/> sub:<img style="vertical-align:sub" src="https://mdn.mozillademos.org/files/15189/star.png"/> </p> <p> text-top:<img style="vertical-align:text-top" src="https://mdn.mozillademos.org/files/15189/star.png"/> text-bottom:<img style="vertical-align:text-bottom" src="https://mdn.mozillademos.org/files/15189/star.png"/> 0.2em:<img style="vertical-align:0.2em" src="https://mdn.mozillademos.org/files/15189/star.png"/> -1em:<img style="vertical-align:-1em" src="https://mdn.mozillademos.org/files/15189/star.png"/> 20%:<img style="vertical-align:20%" src="https://mdn.mozillademos.org/files/15189/star.png"/> -100%:<img style="vertical-align:-100%" src="https://mdn.mozillademos.org/files/15189/star.png"/> </p>
#* { box-sizing: border-box; } img { margin-right: 0.5em; } p { height: 3em; padding: 0 .5em; font-family: monospace; text-decoration: underline overline; margin-left: auto; margin-right: auto; width: 80%; }
{{EmbedLiveSample("vertical-align-inline", 1200, 120, "", "", "example-outcome-frame")}}
<table> <tr> <td style="vertical-align: baseline">baseline</td> <td style="vertical-align: top">top</td> <td style="vertical-align: middle">middle</td> <td style="vertical-align: bottom">bottom</td> <td> <p>There is a theory which states that if ever anyone discovers exactly what the Universe is for and why it is here, it will instantly disappear and be replaced by something even more bizarre and inexplicable.</p> <p>There is another theory which states that this has already happened.</p> </td> </tr> </table>
table { margin-left: auto; margin-right: auto; width: 80%; } table, th, td { border: 1px solid black; } td { padding: 0.5em; font-family: monospace; }
{{EmbedLiveSample("vertical-align-table", 1200, 210, "", "", "example-outcome-frame")}}
vertical-align은 오로지 inline과 table-cell 엘리먼트에만 적용된다는 것에 주의하세요: 이 속성을
block level 엘리먼트에 사용할 수 없습니다.
{{cssinfo}}
이 속성은 아래의 키워드들로 지정됩니다.
주로 부모 엘리먼트에 대하여 상대적으로 수직정렬하는 값들:
baseline
sub
super
text-top
text-bottom
middle
(<length> 와 <percentage>에 대해서 음수 값이 허용됩니다.)
다음 두 value는 부모가 아닌 전체 라인에 대해,수직정렬하는 값입니다:
top
bottom
Baseline이 없는 엘리먼트에 대해서는 bottom margin edge가 baseline을 대신하여 사용됩니다.
baseline
(sub
, super
, text-top
, text-bottom
, <length>
, <percentage>
)top
middle
bottom
음수 값이 허용됩니다.
<div>An <img src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a default alignment.</div> <div>An <img class="top" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a text-top alignment.</div> <div>An <img class="bottom" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a text-bottom alignment.</div> <div>An <img class="middle" src="https://mdn.mozillademos.org/files/12245/frame_image.svg" alt="link" width="32" height="32" /> image with a middle alignment.</div>
img.top { vertical-align: text-top; } img.bottom { vertical-align: text-bottom; } img.middle { vertical-align: middle; }
{{EmbedLiveSample("Example")}}
Specification | Status | Comment |
---|---|---|
{{SpecName('CSS3 Transitions', '#animatable-css', 'vertical-align')}} | {{Spec2('CSS3 Transitions')}} | Defines vertical-align as animatable. |
{{SpecName('CSS2.1', 'visudet.html#propdef-vertical-align', 'vertical-align')}} | {{Spec2('CSS2.1')}} | Add the {{cssxref("<length>")}} value and allows it to be applied to element with a {{cssxref("display")}} type of table-cell . |
{{SpecName('CSS1', '#vertical-align', 'vertical-align')}} | {{Spec2('CSS1')}} | Initial definition |
{{Compat("css.properties.vertical-align")}}
vertical-align
, or "How (Not) To Vertically Center Content"