CSS 수직 가운데 배치

539 단어
1 inline-block+text-align+table-cell+vertical-align
.parent{
    text-align: center;
    display: table-cell;
    vertical-align: middle;
}
.child{
    display: inline-block;
}

2 absolute+transform
.parent{
    position: relative;
}
.child{
    position: absolute;
    top:50%;
    left:50%;
    transform: translate(-50%,-50%);
}

3 flex+justify-content+align-items
.parent{
    display: flex;
    justify-content: center;
    align-items:center;
}    

좋은 웹페이지 즐겨찾기