Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Center horizontally and vertically a div in a section and make each section fill the whole page when scrolling

I am trying to code a page where each section fills the whole page. And I am also trying to center vertically and horizontally the divs in each section.
I don’t know if it’s possible, if you guys can enlighten me it would be great.
I also would like to know if it’s possible that, when I scroll it automatically goes to the next section. I don’t know if it’s clear enough to understand.

Here’s the CSS :

.presta .container {

    width: 100%;
    position: relative;
    
}

.presta .h1 {
    font-size: 80px;
    font-weight: bold;
}

.presta card {

    padding: 30px;
    margin: 0 auto;
}

.logoPresta:hover {
    transition: transform 0.3s ease-in;
    transform: translateY(-10px);
}


.prestaShow {
    text-align: center;
}

.wrapper {
    min-height: 100%;
}

And here’s the HTML :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<body>
        <div class="navbar ">
            <div class="container flex">
              <div class="logo" data-aos="fade-right">
                <a href="index.html"><img src="images/linko_bg_transp.png" alt=""
                /></a>
              </div>
              <nav data-aos="fade-in">
                <ul>
                  <li><a href="index.html">Accueil</a></li>
                  <li><a href="pres.html">Présentation</a></li>
                  <li><a href="Presta.html">Nos Prestations</a></li>
                  <li><a href="form.html">Nous contacter</a></li>
                </ul>
              </nav>
            </div>
          </div>

          <section class="presta bg-light wrapper">
            <div class="container">
              <div class="text-center">
                <h1>Nos domaines d'expertises</h1>
              </div>
              <div class="grid grid-4">
                <div class="logoPresta card">
                    <img src="images/1.jpg" alt="">
                </div>
                <div class="logoPresta card">
                    <img src="images/2.jpg" alt="">
                </div>
                <div class="logoPresta card">
                    <img src="images/3.jpg" alt="">
                </div>
                <div class="logoPresta card">
                    <img src="images/4.jpg" alt="">
                </div>
              </div>
            </div>
          </section>

          <section class="prestaShow wrapper">
            <div class="container info">
              <div class="text-center">
                <h2>Informatique</h2>
              </div>
              <div class="textePresta card">
                Conception & développement d'applications web
              </div>
              <div class="textePresta card">
                Création & amélioration de bases de données
              </div>
              <div class="textePresta card">
                Déploiement d'infrastructures réseaux
              </div>

            </div>
          </section>

Here are the images of the page :
First section
second section

>Solution :

You can resize section to full page height by changing 100% to 100vh

Also, take a look at CSS section to see how to center wrappers’ content (expand Code snippet to see differences)

.presta .container {
  width: 100%;
  position: relative;
}

.presta .h1 {
  font-size: 80px;
  font-weight: bold;
}

.presta card {
  padding: 30px;
  margin: 0 auto;
}

.logoPresta:hover {
  transition: transform 0.3s ease-in;
  transform: translateY(-10px);
}

.prestaShow {
  text-align: center;
}

.wrapper {
  /* centering wrapper content */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">


<div class="navbar ">
  <div class="container flex">
    <div class="logo" data-aos="fade-right">
      <a href="index.html"><img src="images/linko_bg_transp.png" alt="" /></a>
    </div>
    <nav data-aos="fade-in">
      <ul>
        <li><a href="index.html">Accueil</a></li>
        <li><a href="pres.html">Présentation</a></li>
        <li><a href="Presta.html">Nos Prestations</a></li>
        <li><a href="form.html">Nous contacter</a></li>
      </ul>
    </nav>
  </div>
</div>

<section class="presta bg-light wrapper">
  <div class="container">
    <div class="text-center">
      <h1>Nos domaines d'expertises</h1>
    </div>
    <div class="grid grid-4">
      <div class="logoPresta card">
        <img src="images/1.jpg" alt="">
      </div>
      <div class="logoPresta card">
        <img src="images/2.jpg" alt="">
      </div>
      <div class="logoPresta card">
        <img src="images/3.jpg" alt="">
      </div>
      <div class="logoPresta card">
        <img src="images/4.jpg" alt="">
      </div>
    </div>
  </div>
</section>

<section class="prestaShow wrapper">
  <div class="container info">
    <div class="text-center">
      <h2>Informatique</h2>
    </div>
    <div class="textePresta card">
      Conception & développement d'applications web
    </div>
    <div class="textePresta card">
      Création & amélioration de bases de données
    </div>
    <div class="textePresta card">
      Déploiement d'infrastructures réseaux
    </div>

  </div>
</section>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading