Search code examples
htmlcsstwitter-bootstraplayoutbootstrap-5

Bootstrap 5 Images + Additional centered content


I'm currently in the process of learning Bootstrap (5) and attempting a more "advanced" layout. The concept is two images side-by-side with titles below each and with a div centered in-between both. The end result will see them in a horizontal row of 3.

Here's what I'm trying to achieve.

I have numerous variations of this but they all look as bad as each other, any guidance on this would be greatly appreciated, thank you!


Solution

  • This is the best I can come up with using your image. :)

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <link
          href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
          rel="stylesheet"
          integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65"
          crossorigin="anonymous"
        />
    
        <title>Bootstrap Example</title>
      </head>
      <body>
        <div class="container">
          <div class="row position-relative">
            <div class="image1 w-50 col-6"></div>
            <div class="image2 w-50 col-6"></div>
            <div
              class="circle rounded-circle position-absolute top-50 start-50 translate-middle"
            ></div>
          </div>
          <div class="row">
            <div class="title1 col-6 text-center">Title 1</div>
            <div class="title2 col-6 text-center">Title 2</div>
          </div>
        </div>
      </body>
      <style>
        .image1 {
          height: 300px;
          background: red;
        }
        .image2 {
          height: 300px;
          background: blue;
        }
        .circle {
          width: 100px;
          height: 100px;
          background: black;
        }
        .title1 {
          background: purple;
        }
        .title2 {
          background: green;
        }
      </style>
    </html>