Let's say I want to center the h1 and p elements in the division.
<div id="outer" class="container">
<div id="inner">
<h1>Heading</h1>
<p>Some content</p>
</div>
</div>
It is very easy makes the parent div as display: flex
and make the child element margin: auto;
Check the demo below.
#outer {
width: 100%;
height: 100vh;
display: flex;
}
#inner {
margin: auto;
}
<div id="outer" class="container">
<div id="inner">
<h1>Heading</h1>
<p>Some content</p>
</div>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With