vertically align h1 in div

Alright, so you’re trying to vertically align an h1 tag in a div, and CSS is giving you a hard time? Fret not! I’ve got a quick code React.js snippet here with the CSS you need to center your h1 tag in your div:

export default function Home() {
return(
<div
style={{
position: 'absolute',
display: 'flex',
alignItems: 'center',
height: '100%',
width: '100%',
top: 0,
bottom: 0,
margin: 0,
padding: 0,
backgroundColor: 'purple'
}}
>
<h1
style={{
textAlign: 'center',
width: '100%'
}}
>Vertically & Horizontally Centered Text Here</h1>
</div>
);
}
 

topherPedersen