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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
); | |
} |