0

I am new to learning coding, and I cannot figure out how to get my h2 element and img element in the middle of a webpage with the image below the h2 element?? Each time I try to center them I get both in the middle next to each other.

<div class="centered-photo">
    <h2>Below is image of coding</h2>
    <img src="https://www.njea.org/wp-content/uploads/2014/10/Coding.jpg" alt="image of coding" target="_blank" id="home-photo">
</div>

.centered-photo {
    display: flex;
    justify-content: center;
}
caseyle
  • 31
  • 3
  • Add: `margin: auto;` to the child element. If you have one. If you have multiple you can try with `align-items: center;` but that can cause overscroll issues. – Roko C. Buljan Sep 28 '21 at 23:05

0 Answers0