flex box로 수평수직 가운데 정렬하기

index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<style>
html {
height: 100vh;
}

body {
height: 100%;
}

.flexbox-container {
display: flex;
height: 100%;
justify-content: center;
align-items: center;
}

.flexbox-item {
background-color: #ddd;
}
</style>

<div class="flexbox-container">
<div class="flexbox-item">hello world!</div>
</div>
1
2
3
4
.flexbox-container {
justify-content: center;
align-items: center;
}
  • flex box로 수평수직 가운데 정렬하기