Some other old-school methods from the time before flexbox that spring to mind.
Use position:absolute with margins.
position:absolute
.child { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; width: -moz-fit-content; width: fit-content; height: 0; }
::before
inline-block
.parent { text-align: center; font-size:0; } .parent::before { content: ''; height: 100vh; vertical-align: middle; display: inline-block; } .child { vertical-align: middle; display:inline-block; font-size:1rem; }
.parent { line-height:100vh; text-align:center; } .child { display:inline-block; line-height:1.2rem; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Some other old-school methods from the time before flexbox that spring to mind.
Use
position:absolute
with margins.And the ghost
::before
inline-block
box;And the line-height method