Approach 4 - Absolutely positioned 50% from the top with displacement:
Approach 5 - The line-height method (Least flexible - not suggested):
Horizontally
Is it inline or inline-* elements (like text or links)?
Is it a block level element?
Is there more than one block level element?
Vertically
Vertical centering is a bit trickier in CSS.
Is it inline or inline-* elements (like text or links)?
Is it a block-level element?
Both Horizontally and Vertically
You can combine the techniques above in any fashion to get perfectly centered elements. But I find this generally falls into three camps:
Is the element of fixed width and height?
Is the element of unknown width and height?
Can you use flexbox?
Conclusion
You can totally center things in CSS.
See www.medium.com/@Snowmanzzz/how-to-center-an-element-horizontally-and-vertically-54129e20ebe7
How to center an element horizontally and vertically? Ask Question
http://stackoverflow.com/questions/19461521/how-to-center-an-element-horizontally-and-vertically
Approach 1 - transform translateX/translateY:
Approach 2 - Flexbox method:
Approach 3 - table-cell/vertical-align: middle:
Approach 4 - Absolutely positioned 50% from the top with displacement:
Approach 5 - The line-height method (Least flexible - not suggested):
Horizontally Is it inline or inline-* elements (like text or links)? Is it a block level element? Is there more than one block level element?
Vertically Vertical centering is a bit trickier in CSS. Is it inline or inline-* elements (like text or links)? Is it a block-level element?
Both Horizontally and Vertically You can combine the techniques above in any fashion to get perfectly centered elements. But I find this generally falls into three camps: Is the element of fixed width and height? Is the element of unknown width and height? Can you use flexbox?
Conclusion You can totally center things in CSS.
See www.medium.com/@Snowmanzzz/how-to-center-an-element-horizontally-and-vertically-54129e20ebe7