CSS에서 요소를 세로로 가운데에 맞추려면 상단 및 하단 패딩을 사용하세요.
예시
다음 코드를 실행하여 요소를 중앙에 배치할 수 있습니다.
<!DOCTYPE html>
<html>
<head>
<style>
.center {
padding: 50px 0;
border: 2px solid blue;
}
</style>
</head>
<body>
<h2>Center Vertically</h2>
<p>In this example, we use the padding property to center the div element vertically:</p>
<div class = "center">
<p>I am vertically centered.</p>
</div>
</body>
</html> 출력
