Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Flex box Responsive Layout with Left and Right Container

I have trouble with flexbox layout in mobile device. Desktop it looks okay in Mobile view I want to display like below

  1. first it should display "Overview" Box
  2. second it should display "Payment" Box
  3. 3rd it should display "Activity" Box

.div1 {
  box-sizing:border-box;
  border:0.5px solid red;
}

.main-container {
  height:100%;
  display:flex;
}

.left-container {
  flex:1 1 0;
}

.right-container {
  flex:1 1 0;
  display:flex;
  //flex-direction:column; 
}

.half-containers {
  flex:1;
  overflow:auto;
  order: 1;
}

.half-containers-activity {
  flex:1;
  overflow:auto;
  order: 0;
}

@include media-breakpoint-down(sm) {
  .main-container {
    flex-direction: row;

      }
}
<div class="div1">
  <div class="main-container">
    <div class="left-container">
      <div class="half-containers">
        Overview
      </div>
      <div class="half-containers-activity">
        Activity
      </div>
    </div>
    <div class="right-container">
      Payment
    </div>
  </div>
</div>

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use the following method. The main thing here is to use display: contents; on .left-container to "neutralize" it, so that all three elements can be used "on one level" as flex children, applying according order parameters to them. All that in a media query, of course, to leave the desktop version unaltered.

.div1 {
  box-sizing: border-box;
  border: 0.5px solid red;
}

.main-container {
  height: 100%;
  display: flex;
}

.left-container {
  flex: 1 1 0;
}

.right-container {
  flex: 1 1 0;
  display: flex;
  //flex-direction:column; 
}

.half-containers {
  flex: 1;
  overflow: auto;
  order: 1;
}

.half-containers-activity {
  flex: 1;
  overflow: auto;
  order: 0;
}

@media screen and (max-width: 700px) {
  .main-container {
    flex-direction: column;
  }
  .left-container {
    display: contents;
  }
  .half-containers {
    order: 0;
  }
  .right-container {
    order: 1;
  }
  .half-containers-activity {
    order: 2;
  }
}
<div class="div1">
  <div class="main-container">
    <div class="left-container">
      <div class="half-containers">
        Overview
      </div>
      <div class="half-containers-activity">
        Activity
      </div>
    </div>
    <div class="right-container">
      Payment
    </div>
  </div>
</div>

I should add that display: contents; is still regarded an "experimental value", but browser support is quite good already: https://caniuse.com/?search=display%3A%20contents

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!