0

I am trying to build following site.

enter image description here

I cant figure out how I can make the flexbox in the center of the Image. What am I doing wrong?

.background {
    max-height: 700px;
    max-width: 1200px;
    margin: auto;
}
.container {
    display: flex;
    flex-direction: column;
    background-color: black;
    width: 1200px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}
    <div class="background">
        <img src="../FlexBox Project/Pictures/img-mission-background.jpg">
        <div class="container">
            <div class="header">
                <h2>Our Mission</h2>
            </div>
        </div>
    </div>
isherwood
  • 58,414
  • 16
  • 114
  • 157

2 Answers2

0

Maybe it will work with following code:

.header {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.background {
    max-height: 700px;
    max-width: 1200px;
    margin: auto;
}
.container {
    display: flex;
    flex-direction: column;
    background-color: black;
    width: 1200px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}
<div class="background">
        <img src="https://via.placeholder.com/600">
        <div class="container">
            <div class="header">
                <h2>Our Mission</h2>
            </div>
        </div>
    </div>
isherwood
  • 58,414
  • 16
  • 114
  • 157
Sven Märki
  • 189
  • 1
  • 12
  • This doesn't center the content very well. – isherwood Mar 11 '22 at 16:43
  • 1
    That helped in bringing the Header above the Image. Its not Centered yet unfortunatly. Also i was hoping i would be able to do it using a flexbox. But the Answer already helped thanks. – LoneMeloen Mar 11 '22 at 16:49
-1

Have you tried wrapping the div: class="header" element in a center element?