As promised, a simple project
HTML
<div class="row"> <div class="col1">DIV A</div> <div class="col2">DIV B</div> <div class="col3">DIV C</div> </div>
CSS
.row { display: flex; flex-wrap: wrap; flex-direction: row; justify-content: space-between; width: 400px; margin: 0 auto; } .col1 { width: 200px; height: 400px; background-color: #86a0ff; } .col2 { width: 150px; height: 150px; background-color: #ff6cde; } .col3 { margin-top: -200px; margin-left: auto; width: 150px; height: 150px; background-color: #35af6d; } @media (max-width: 768px) { .row { justify-content: center; flex-direction: column; } .col1 { order: 2; width: 200px; margin-top: 50px; } .col2 { order: 1; width: 200px; } .col3 { order: 3; width: 200px; margin-top: 50px; margin-left: 0; } }
As for the explanation, here is a great guide to flexbox. The main idea in my example is that using the order property you can control the display order of the blocks. The main advantage of using flexbox is that you do not need to load any library (for example, Bootstrap) to achieve the desired result, for example, response. And it also has good browser support if you don't need support for older browsers. I hope my answer will be useful to you!
source share