65

We all know it's true

Comments
  • 2
    This is incredible.
  • 2
    display: table; for the parent, with height

    display: table-cell; and vertical-align: middle; for the child

    Oe justo use flexbox
  • 1
    @zavan doesn't work if the parent height is in percent
  • 1
    I always do

    parent {
    }

    child {
    margin-top: 50%;
    transform: translateY(-50%);
    }
  • 1
    Advice from the Treehouse CSS course that worked for me:

    #Parent {
      position: relative;
    }

    #Child {
      position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;

    }
  • 0
    .parent {
    display: flex;
    align-items: center;
    }
Add Comment