본문 바로가기
IT/web

[css] width, height 알 수 없는 div, 가로 세로 모두 가운데 정렬하기

by 내일은교양왕 2024. 4. 21.

transform을 이용해서 해결 가능합니다.

translate % 설정은 자기 자신의 기준으로 계산합니다. .

우리는 height값을 모르지만, transfrom은 알고 있다.

 

 

See the Pen make div center vertically and horizontally by Daewoong Kim (@daewoong-kim) on CodePen.

 

https://www.youtube.com/watch?v=78-X1JGvCZU

'IT > web' 카테고리의 다른 글

[css] body에 배경을 변경했을 때  (0) 2024.04.22
[css] 마진병합  (0) 2024.04.21
[css] em, rem  (0) 2024.04.21
[css] line-height  (0) 2024.04.21
[css] div 가로세로 가운데 정렬  (0) 2024.04.19