There are several ways to centralize the content of a <div>
vertically. However, when it comes to a height other than in pixels, people are beginning to wonder if there is an efficient method for doing this.
I created a form that I found to be efficient and came here looking for someone who offers a better proposal, since one of the biggest difficulties that a front end finds today is centering a content of a div that does not have height in pixels .
HTML:
<section>
<article>
<div>
<p>Centro</p>
</div>
</article>
</section>
CSS:
section{
position: relative;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #ddd;
display: flex;
flex-direction: column;
}
article{
flex: 1;
display: flex;
margin: 0 auto;
}
article > div{
margin: auto 0;
}
Demo: link