[CSS] 수직/수평 정렬

- block의 경우 (예를 들어, div)

margin: auto로 수평 center 가능하다. (수직으로는 불가능)

- text-align의 경우

요소를 수평 center 가능하지만 수직으로는 불가능하다.

블록 요소에는 적용이 안 된다.

-transform: translate(50%, 50%)

translate(x축, y축)이다. 50씩 이동하므로 완전한 center.

-텍스트인 경우

text-align: center

line-height: __px (__에는 부모 상자의 height 만큼 넣어주면 된다.)

그냥 justify-content를 사용하도록 하자...

 

developer.mozilla.org/en-US/docs/Web/CSS/justify-content

 

justify-content - CSS: Cascading Style Sheets | MDN

The CSS justify-content property defines how the browser distributes space between and around content items along the main-axis of a flex container, and the inline axis of a grid container. The interactive example below demonstrates some of the values usin

developer.mozilla.org

 

320x100