Home > Net >  flexbox can't align each other
flexbox can't align each other

Time:08-29

For some reason I can't align the flex boxes to each other. is there a way to align it? Thanks!

.services {
  width: 80%;
  margin: auto;
  text-align: center;
  padding-top: 100px;
}

h1 {
  font-size: 36px;
  font-weight: 600;
}

p {
  color: #777;
  font-size: 14px;
  font-weight: 300;
  line-height: 22px;
  padding: 10px;
}

.row {
  margin-top: 5%;
  display: flex;
  justify-content: space-between;
}

.services-col {
  flex-basis: 31%;
  background: #fff3f3;
  border-radius: 10px;
  margin-bottom: 5%;
  padding: 20px 12px;
  box-sizing: border-box;
  transition: 0.5s;
}

h3 {
  text-align: center;
  font-weight: 600;
  margin: 10px 0;
}

.services-col:hover {
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}
<section >
  <h1>Services We Offer</h1>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>

  <div >
    <div >
      <h3>Concrete Machinery Installation</h3>
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat minus aliquid incidunt suscipit, dolores qui magnam a obcaecati voluptates nesciunt!</p>
    </div>

    <div >
      <div >
        <h3>Electrical and Automation</h3>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat minus aliquid incidunt suscipit, dolores qui magnam a obcaecati voluptates nesciunt!</p>
      </div>

      <div >
        <div >
          <h3>Heavy Equipments</h3>
          <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat minus aliquid incidunt suscipit, dolores qui magnam a obcaecati voluptates nesciunt!</p>
        </div>

      </div>
</section>

CodePudding user response:

I think the display: flex should wrap all .services-col. Also, some end tag </div> were missing.

.services{
        width: 80%;
        margin: auto;
        text-align: center;
        padding-top: 100px;
        
    }
    h1{
        font-size: 36px;
        font-weight: 600;
    }
    p{
        color: #777;
        font-size: 14px;
        font-weight: 300;
        line-height: 22px;
        padding: 10px;
    }
    
    .row{
        margin-top: 5%;
        display: flex;
        justify-content: space-between;
   
    }
    .services-col{
        flex-basis: 31%;
        background: #fff3f3;
        border-radius: 10px;
        margin-bottom: 5%;
        padding: 20px 12px;
        box-sizing: border-box;
        transition: 0.5s;
    }
    h3{
        text-align: center;
        font-weight: 600;
        margin: 10px 0;
    }
    .services-col:hover{
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
    }
<section >
   <h1>Services We Offer</h1>
   <p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
   <div >
      <div >
         <h3>Concrete Machinery Installation</h3>
         <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat minus aliquid incidunt suscipit, dolores qui magnam a obcaecati voluptates nesciunt!</p>
      </div>
      <div >
         <h3>Electrical and Automation</h3>
         <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat minus aliquid incidunt suscipit, dolores qui magnam a obcaecati voluptates nesciunt!</p>
      </div>
      <div >
         <h3>Heavy Equipments</h3>
         <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Placeat minus aliquid incidunt suscipit, dolores qui magnam a obcaecati voluptates nesciunt!</p>
      </div>
   </div>
</section>

  • Related