This: vertical centering works great Code:
` <div class="container"> <h1>Vertical center with only 3 lines of code</h1> <section class="text"> <p>I'm vertically aligned! Hi ho Silver, away!</p> </section> </div>`
However, if I try to center horizontally using the same approach, using
left: 50%; translateX(-50%);
after splitting two lines in the .container element in CSS I get a strange result: the container is centered horizontally, but the vertical centering is lost. What am I missing here and how to achieve what I want: to center the container vertically and horizontally on the page using translateX / Y?
source share