Trying to center a div containing some text in a very simple website I'm doing. Managed to get in centered vertically but cannot get in centered horizontally:
#welcome-section{
border: 10px solid blue;/*temporary for control*/
display: block;
height: 100vh;/*U.S. 10 100% viewport height*/
width: 100vw;/*100% viewport width*/
background-color: red;
color: white;
}
.hellotext{
position: absolute;
top: 50%;
border: 10px solid pink;
}
<body>
<header id="welcome-section"><!--U.S. 1-->
<div class="hellotext">
<h1>¡Hola! I'm Carlos</h1><!--U.S. 2-->
<h4>text text text</h4>
</div>
</header><!--U.S. 1-->
</body>
I would want the h1 and h4 to be horizontally and vertically aligned, and ideally responsive, and always stay bang in the middle.