Centering vertically using (only) CSS

You wrote on your resume that you have advanced knowledge on CSS. A recruiter calls you and asks one question: You said you have advanced knowledge on CSS… Prove it! How do you center elements vertically?

All hell breaks lose and you start asking yourself what have you done with your life…

Well, not anymore, the following code may help you:

position: relative; 
top: 50%; 
transform: translateY(-50%);

That snippet may need a few tweeks, but it has worked for me so far.

Good luck!

The following two tabs change content below.
Software Architect and Backend Developer (almost Fullstack), I usually work with C#, PowerShell, Python, Golang, bash and Unity (this one is more for a hobby). I'm always looking for something new to learn, adding new tools to my utility belt.
Posted in Dev, General KB and tagged , , , , , , , .