My approach to this problem involves using Bootstrap and jQuery for a simple example, although I'm not sure how your code looks.
function resized(element) {
const $element = $(element);
const $box3 = $('.box3');
if ($element.width() < 768) {
$box3.insertBefore($(".box2"));
} else {
$(".box3-container").append($box3);
}
}
$(document).ready(() => {
resized(window);
});
$(window).on("resize", e => {
resized(e.target);
})
body {
font-family: sans-serif;
}
.box1,
.box2 {
width: 200px;
height: 100px;
color: #fff;
}
.box3 {
width: 300px;
height: 300px;
color: #fff;
}
.box2 {
background: red;
}
.box1 {
background: green;
}
.box3 {
background: blue;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="box-container d-flex flex-column">
<div
class="box1 d-flex justify-content-center align-items-center m-3 text-uppercase"
>
box1
</div>
<div
class="box2 d-flex justify-content-center align-items-center m-3 text-uppercase"
>
box2
</div>
</div>
</div>
<div class="col-md-6 box3-container">
<div
class="box3 6 d-flex justify-content-center align-items-center text-uppercase m-3"
>
box3
</div>
</div>
</div>
</div>
Check out the example on Codepen: https://codepen.io/pglejzer/pen/OJVbaXW?editors=1010