-2

I'm trying to make each sections content centered. How do I do this?

see attached image: enter image description here section 1 100vh, content in middle of page section 2 100vh, content in middle of page

.content {
    height: 100vh;
}
<!doctype html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Test</title>

        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
        <link rel="stylesheet" href="{{ url_for('static', filename='css/index.css') }}" />
    </head>
    <body>
    <section class="content" style="background-color: lightgreen;">
        <div class="container">
            <div class="row">
                <div class="col-lg-6 text-center text-lg-start">
                    <h1>heading</h1>
                    <p>test</p>
                </div>

                <div class="col-lg-6">
                    <img src="https://via.placeholder.com/350/09f/fff.png" />
                </div>
            </div>
        </div>
    </section>

    <section class="content" style="background-color: moccasin;">
        <div class="container">
            <div class="row">
                <div class="col-lg-6">
                    <h1>heading</h1>
                    <p>test</p>
                </div>

                <div class="col-lg-6">
                    <img src="https://via.placeholder.com/350/09f/fff.png" />
                </div>
            </div>
        </div>
    </section>
                <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
    </body>
</html>

using bootstrap v5.3.0-alpha1

1 Answers1

0

You need to use the flexbox property to center the content of the both section:

.content {
  height: 100vh;
  display: flex;
  align-items: center;
 }
Yash porwal
  • 301
  • 3
  • 9