0

What is the best way to center div in the middle of another element?

I have an container with with set to 100% and height to 130% of the screen but i fail to centr it int the middle ( of the container ). i tried using

div {
    margin: auto;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    position: absolute;
    text-align: center;
    vertical-align: middle;
}

But this will just set the the content of div in the middle horizontally only , and set the width and height of the inner element to container element.

What is the best trick to achieve such thing? Here is demo

Darlyn
  • 4,715
  • 12
  • 40
  • 90

0 Answers0