How to center image group with flexbox

Asked

Viewed 32 times

-2

I’m trying to center the images using the: Justify-content: center; tried in many ways but I could not get someone can give a strength?
I want the images to be in the center of the screen with margin-left: 20px, but I’m not getting.

*{
    margin: 0;
    padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&display=swap');

.paidocontainjsjl {
    display: flex;

  flex-wrap: wrap;
    background-color: antiquewhite;
    padding-top: 90px;
    padding-bottom: 90px;
    font-family: 'Poppins', sans-serif;
}


#humcentrimmm {
position: absolute;
top: 30px;
left: 50%;
z-index: 1;
transform: translateX(-50%);
}

#humcentrimmm h1{
text-transform: uppercase;
font-weight: bold;
font-size: 37px;
}

.boxdaimgsds {
    position: relative;
    z-index: 10;
    width: 200px;
    margin: 0 auto;
}

.boxdaimgsds img {
    width: 200px;
    z-index: -99;
    margin-top: 40px;
}

.boxtexto {
    width: 200px;
    position: absolute;
    bottom: -20px;
    margin-top: -100px;
    background-color: salmon;
    padding-top: 10px;
    padding-bottom: 10px;
    text-align: center;
    color: #fff;
    font-size: 23px;
    font-weight: bold;
    z-index: 888;
    text-transform: uppercase;
}
.boxtexto::after {
    content: "";
  position: absolute;
  left: 0;
  bottom: 50px;
 background-color: salmon;
 clip-path: polygon(0 78%, 100% 93%, 100% 100%, 0% 100%);
 width: 100%;
 height: 100%;
}

@media (max-width:1087px) {
    .boxdaimgsds {
        margin-top: 50px;
    }

    #humcentrimmm  {
        top: 40px;
    }
    .boxdaimgsds img {
        width: 200px;
        z-index: -99;
        margin-top: 0px;
    }
    
}
  
<div class="paidocontainjsjl">
    <div id="humcentrimmm">
        <h1>Produtos</h1>
    </div>
        <div class="boxdaimgsds">
            <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
            <div class="boxtexto">Texto</div>
        </div>

        <div class="boxdaimgsds">
            <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
            <div class="boxtexto">Texto</div>
        </div>

        <div class="boxdaimgsds">
            <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
            <div class="boxtexto">Texto</div>
        </div>

        <div class="boxdaimgsds">
            <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
            <div class="boxtexto">Texto</div>
        </div>

    </div>  

inserir a descrição da imagem aqui

1 answer

-1


In class .paidocontainjsjl you put the justify-content: center; and in the images you put the margin the way you want, as it is 20px I suggest margin: 0 10px;

inserir a descrição da imagem aqui

* {
  margin: 0;
  padding: 0;
}

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&display=swap');

.paidocontainjsjl {
  display: flex;

  flex-wrap: wrap;
  background-color: antiquewhite;
  padding-top: 90px;
  padding-bottom: 90px;
  font-family: 'Poppins', sans-serif;

  justify-content: center;
}


#humcentrimmm {
  position: absolute;
  top: 30px;
  left: 50%;
  z-index: 1;
  transform: translateX(-50%);
}

#humcentrimmm h1 {
  text-transform: uppercase;
  font-weight: bold;
  font-size: 37px;
}

.boxdaimgsds {
  position: relative;
  z-index: 10;
  width: 200px;
  margin: 0 10px;
}

.boxdaimgsds img {
  width: 200px;
  z-index: -99;
  margin-top: 40px;
}

.boxtexto {
  width: 200px;
  position: absolute;
  bottom: -20px;
  margin-top: -100px;
  background-color: salmon;
  padding-top: 10px;
  padding-bottom: 10px;
  text-align: center;
  color: #fff;
  font-size: 23px;
  font-weight: bold;
  z-index: 888;
  text-transform: uppercase;
}

.boxtexto::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 50px;
  background-color: salmon;
  clip-path: polygon(0 78%, 100% 93%, 100% 100%, 0% 100%);
  width: 100%;
  height: 100%;
}

@media (max-width:1087px) {
  .boxdaimgsds {
    margin-top: 50px;
  }

  #humcentrimmm {
    top: 40px;
  }

  .boxdaimgsds img {
    width: 200px;
    z-index: -99;
    margin-top: 0px;
  }

}
<div class="paidocontainjsjl">
  <div id="humcentrimmm">
    <h1>Produtos</h1>
  </div>
  <div class="boxdaimgsds">
    <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
    <div class="boxtexto">Texto</div>
  </div>

  <div class="boxdaimgsds">
    <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
    <div class="boxtexto">Texto</div>
  </div>

  <div class="boxdaimgsds">
    <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
    <div class="boxtexto">Texto</div>
  </div>

  <div class="boxdaimgsds">
    <img src="https://www.w3schools.com/howto/img_avatar.png" alt="">
    <div class="boxtexto">Texto</div>
  </div>

</div>

  • 1

    ! Thank you worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.