Vertically center align elements on page

PHOTO EMBED

Fri Jan 01 2021 07:43:06 GMT+0000 (Coordinated Universal Time)

Saved by @eneki #php

// Importing Google font
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;1,700&display=swap');

// Any margins or padding added to any element won't affect its width
* {
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
  // This is the easiest way to center align content vertically
    display: flex;
  // The default direction elements are stacked is side by side (horizontally). This changes it to top to bottom (vertially)
    flex-direction: column;
  // Horizontally center
    align-items: center;
  // Vertically center - must have a height to work
    justify-content: center;
    height: 100vh;
  // Scroll bars are hidden by default
    overflow: hidden;
}
content_copyCOPY