본문 바로가기
JavaScript

정렬

by 박길치 2021. 6. 29.

1. 가로로 가운데 정렬

-inline/inline-block요소

부모 태그에 text-align: center; 작성

 

-block 요소

margin-left: auto;

margin-right: auto; 작성

 

2. 세로로 가운데 정렬

display: inline-block;

line-height: (요소의 height)px;

vertical-align: middle;

하면 됨.

주의사항!

line-height는 상속되기 때문에 자식 태그들에는 line-height: normal;을 써줘야함

 

 

 

 

참고링크

https://css-tricks.com/centering-css-complete-guide/

 

Centering in CSS: A Complete Guide | CSS-Tricks

Centering things in CSS is the poster child of CSS complaining. Why does it have to be so hard? They jeer. I think the issue isn't that it's difficult to

css-tricks.com

 

 

'JavaScript' 카테고리의 다른 글

Float  (0) 2021.06.30
Position  (0) 2021.06.30
Display  (0) 2021.06.28
CSS 선택자  (0) 2021.06.28
Box Model  (0) 2021.06.22