Home > Blockchain >  Center horizontally and vertically a div in a section and make each section fill the whole page when
Center horizontally and vertically a div in a section and make each section fill the whole page when

Time:01-31

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 :

<body>
        <div >
            <div >
              <div  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 >
            <div >
              <div >
                <h1>Nos domaines d'expertises</h1>
              </div>
              <div >
                <div >
                    <img src="images/1.jpg" alt="">
                </div>
                <div >
                    <img src="images/2.jpg" alt="">
                </div>
                <div >
                    <img src="images/3.jpg" alt="">
                </div>
                <div >
                    <img src="images/4.jpg" alt="">
                </div>
              </div>
            </div>
          </section>

          <section >
            <div >
              <div >
                <h2>Informatique</h2>
              </div>
              <div >
                Conception & développement d'applications web
              </div>
              <div >
                Création & amélioration de bases de données
              </div>
              <div >
                Déploiement d'infrastructures réseaux
              </div>

            </div>
          </section>

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

CodePudding user response:

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).

UPD: .snap-wrapper will help you to scroll full sections, take a look at Code snippet on full-screen.

.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;
}

/* use .snap-wrapper to scroll page by full sections */
.snap-wrapper {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  scroll-snap-type: y mandatory;
  overflow: auto;
  height: 100vh;
}

.snap-wrapper > .wrapper {
  scroll-snap-align: center;
}
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">


<div >
  <div >
    <div  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>

<div >
  <section >
    <div >
      <div >
        <h1>Nos domaines d'expertises</h1>
      </div>
      <div >
        <div >
          <img src="images/1.jpg" alt="">
        </div>
        <div >
          <img src="images/2.jpg" alt="">
        </div>
        <div >
          <img src="images/3.jpg" alt="">
        </div>
        <div >
          <img src="images/4.jpg" alt="">
        </div>
      </div>
    </div>
  </section>

  <section >
    <div >
      <div >
        <h2>Informatique</h2>
      </div>
      <div >
        Conception & développement d'applications web
      </div>
      <div >
        Création & amélioration de bases de données
      </div>
      <div >
        Déploiement d'infrastructures réseaux
      </div>

    </div>
  </section>
</div>

  •  Tags:  
  • Related