skip to Main Content

I don’t know what am missing here. I’m trying to make a 2×2 box with display:flex with these 4 articles. What can I do now? I can’t get it to work. I also wrapped all the div’s into a

@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:700|Roboto:100,300,700');


html,body{
  margin:0;
  padding:0;
  font-family: Roboto;
  font-size: 10px;
  line-height:3.5;
  font-weight:300;
}

h1,h2,h3,h4,h5{
  font-family:Roboto Condensed;
}
h1{
  font-size:9em;
  text-align:center;
  text-transform:uppercase;
}
h2{
  font-size:5em;
  text-align:center;
  text-transform:uppercase;
  line-height:4em;
  color:white;
  text-shadow: #020819 8px -20px 9px
}
h3{
  font-size:4.2em;
  text-align:center;
  line-height:1em;
  margin-top:0;
  
}
h4{
  font-size:1.5em;
  letter-spacing:0.4;
  line-height:1em;
  
  
}
h5{
  font-size:1.2em;
  line-height:1em;
  margin-top:0;
  margin-bottom:0;
}









.service-box{
  
  font-size:1.7em;
  text-align:center;
  border:2px solid #eee;
  border-radius:20px;
  boxing-size:border-box;
  box-shadow: 2px 2px 10px 0 #eee;
  margin:50px 5% 0 5%;
  padding:20px;
  width:40%
}
.service-box img{
  width:150px;
}




#structure  div {
  display: flex;
justify-content: space-between;
flex-direction:row;
flex-wrap: wrap;
}
<section id="structure " >
  

  <div>
  <article  class="service-box" >
    <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-training.png">
    <h3>Training</h3>
      
    <p>We teach all the necessary things to jump from the plane without any kind of problem.</p>
  
  </article>
  </div>
  <div >
  <article  class="service-box">
    <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-get-ready.png" >
    <h3>Get Ready</h3>
    
    <p>You are already prepared, you just need the suit and a parachute. All sizes available.</p>
  </article>
  </div>
  <div >
  <article  class="service-box">
    <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-fly.png">
    <h3>Fly</h3>
    
    <p>You are ready, and the plane is waiting for us in the hangar. Let's fly</p>
  </article>
  </div>
  <div >
  <article  class="service-box">
    <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-jump.png">
    <h3>Jump!</h3>
    
    <p>You have done the most complicated. just one step left... jump!!</p>
  </article>
    
</div>
 
</section>

Put a class and selected the #structure .(div class) and set the properties to flex and all and nothing seems to work.

Codepen

2

Answers


  1. you need to change the structure of your html and also change width:40% to width:40vw and you should be all set

    @import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:700|Roboto:100,300,700');
    html,
    body {
      margin: 0;
      padding: 0;
      font-family: Roboto;
      font-size: 10px;
      line-height: 3.5;
      font-weight: 300;
    }
    
    h1,
    h2,
    h3,
    h4,
    h5 {
      font-family: Roboto Condensed;
    }
    
    h1 {
      font-size: 9em;
      text-align: center;
      text-transform: uppercase;
    }
    
    h2 {
      font-size: 5em;
      text-align: center;
      text-transform: uppercase;
      line-height: 4em;
      color: white;
      text-shadow: #020819 8px -20px 9px
    }
    
    h3 {
      font-size: 4.2em;
      text-align: center;
      line-height: 1em;
      margin-top: 0;
    }
    
    h4 {
      font-size: 1.5em;
      letter-spacing: 0.4;
      line-height: 1em;
    }
    
    h5 {
      font-size: 1.2em;
      line-height: 1em;
      margin-top: 0;
      margin-bottom: 0;
    }
    
    .service-box {
      font-size: 1.7em;
      text-align: center;
      border: 2px solid #eee;
      border-radius: 20px;
      
      box-shadow: 2px 2px 10px 0 #eee;
      margin: 50px 5% 0 5%;
      padding: 20px;
      width: 40vw;
    }
    
    .service-box img {
      width: 150px;
    }
    
    .structure {
      display: flex;
      justify-content: space-between;
      flex-direction: row;
      flex-wrap: wrap;
    }
    <section class="structure ">
    
    
      <div>
        <article class="service-box">
          <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-training.png">
          <h3>Training</h3>
    
          <p>We teach all the necessary things to jump from the plane without any kind of problem.</p>
    
        </article>
      </div>
      <div>
        <article class="service-box">
          <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-get-ready.png">
          <h3>Get Ready</h3>
    
          <p>You are already prepared, you just need the suit and a parachute. All sizes available.</p>
        </article>
      </div>
    </section>
    <section class="structure ">
      <div>
        <article class="service-box">
          <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-fly.png">
          <h3>Fly</h3>
    
          <p>You are ready, and the plane is waiting for us in the hangar. Let's fly</p>
        </article>
      </div>
      <div>
        <article class="service-box">
          <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-jump.png">
          <h3>Jump!</h3>
    
          <p>You have done the most complicated. just one step left... jump!!</p>
        </article>
    
      </div>
    
    </section>
    Login or Signup to reply.
  2. You are wanting a 2×2 grid, therefore you should be using Grid instead of Flexbox.

    #structure  {
      display: grid;
      grid-template-columns: 1fr 1fr;
    }
    
    @import url('https://fonts.googleapis.com/css?family=Roboto+Condensed:700|Roboto:100,300,700');
    
    
    html,body{
      margin:0;
      padding:0;
      font-family: Roboto;
      font-size: 10px;
      line-height:3.5;
      font-weight:300;
    }
    
    h1,h2,h3,h4,h5{
      font-family:Roboto Condensed;
    }
    h1{
      font-size:9em;
      text-align:center;
      text-transform:uppercase;
    }
    h2{
      font-size:5em;
      text-align:center;
      text-transform:uppercase;
      line-height:4em;
      color:white;
      text-shadow: #020819 8px -20px 9px
    }
    h3{
      font-size:4.2em;
      text-align:center;
      line-height:1em;
      margin-top:0;
      
    }
    h4{
      font-size:1.5em;
      letter-spacing:0.4;
      line-height:1em;
      
      
    }
    h5{
      font-size:1.2em;
      line-height:1em;
      margin-top:0;
      margin-bottom:0;
    }
    
    .service-box{
      font-size:1.7em;
      text-align:center;
      border:2px solid #eee;
      border-radius:20px;
      boxing-size:border-box;
      box-shadow: 2px 2px 10px 0 #eee;
      margin:50px 5% 0 5%;
      padding:20px;
      /* width:40% */
    }
    .service-box img{
      width:150px;
    }
    
    
    #structure  {
      display: grid;
      grid-template-columns: 1fr 1fr;
    }
    <section id="structure">
    
      <article class="service-box">
        <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-training.png">
        <h3>Training</h3>
        <p>We teach all the necessary things to jump from the plane without any kind of problem.</p>
      </article>
    
      <article class="service-box">
        <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-get-ready.png">
        <h3>Get Ready</h3>
        <p>You are already prepared, you just need the suit and a parachute. All sizes available.</p>
      </article>
    
      <article class="service-box">
        <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-fly.png">
        <h3>Fly</h3>
        <p>You are ready, and the plane is waiting for us in the hangar. Let's fly</p>
      </article>
    
      <article class="service-box">
        <img src="https://s3-eu-west-1.amazonaws.com/ih-materials/uploads/ironskydive-jump.png">
        <h3>Jump!</h3>
        <p>You have done the most complicated. just one step left... jump!!</p>
      </article>
    
    </section>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search