Search code examples
csspositioncss-position

CSS: Positioning


So I have the following sequence of html:

<div class="box-content">
   <div class="box1 box"></div>
   <div class="box2 box"></div>
   <div class="box3 box"></div>
</div>

I am trying to display them like the following image:positioning

Does anybody know the appropriate css to do so?


Solution

  • You can do this with Flexbox.

    body, html {
      margin: 0;
      padding: 0;
    }
    
    * {
      box-sizing: border-box;
    }
    
    .box-content {
      display: flex;
      height: 100vh;
      flex-wrap: wrap;
    }
    
    .box {
      border: 3px solid black;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 30px;
      background: #22B14C;
      margin: 10px;
    }
    .box2, .box3{
      flex: 0 0 calc(50% - 20px);
    }
    
    .box1 {
      flex: 0 0 calc(100% - 20px);
    }
    <div class="box-content">
       <div class="box1 box">One</div>
       <div class="box2 box">Two</div>
       <div class="box3 box">Three</div>
    </div>