짬짬이기록하기

flexbox를 이용한 수직 중앙 정렬 본문

Web Development/CSS

flexbox를 이용한 수직 중앙 정렬

짬짬이기록하기 2020. 6. 17. 16:17
반응형

HTML

<div class="container">
    <div class="container-item">middle 정렬</div>
</div>

 

CSS

html {
    height:100%;
    margin:0;
    padding:0;
}

body {
    height:inherit;
    margin:0;
    padding:0;
}

.container {
    height:inherit;
    display: flex;
    justify-content: center;
    align-items: center;
    border:1px solid #000;
 }

 .container-item {
    width:30%;
    padding:10px;
    background-color:#ddd;
    text-align:center;
 }

 

Result 

 

 

반응형

'Web Development > CSS' 카테고리의 다른 글

flex box 아리송한 것 정리  (0) 2023.05.24
em rem 적절한 사용  (0) 2023.02.22
table layout case  (0) 2022.07.21
행 열 쉽게 외우기  (0) 2020.06.23
input radio checked를 이용한 tab 메뉴 만들기  (0) 2020.06.16