I'm currently exploring the world of responsive web development using media queries, and I have a question - is it feasible to shift an element from one div to another without relying on a script?
In the desktop view, the layout should be like this:
---------
div1 | | div2
div3 | image | div4
div5 | | div6
---------
which is the desired arrangement.
On mobile screens, I envision the layout as follows:
---------
| |
| image |
| |
---------
div1
div2
div3
div4
div5
div6
However, I seem to face difficulties in moving divs beyond their parent divs.
Below is the HTML code:
<!DOCTYPE html>
<html>
<head>
<meta charset = "UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Shuffle</title>
</head>
<body>
<div class="header">
<h1>Shuffle</h1>
</div>
<div id="main">
<div class="leftBox">
<div class="boxItem" id="first">
<p>1</p>
</div>
<div class="boxItem" id="third">
<p>3</p>
</div>
<div class="boxItem" id="fifth">
<p>5</p>
</div>
</div>
<div class="image">
<img src="https://images.unsplash.com/photo-1605842581240-a0e2527d200b?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjE0NTg5fQ">
</div>
<div class="rightBox">
<div class="boxItem" id="second">
<p>2<p>
</div>
<div class="boxItem" id="fourth">
<p>4</p>
</div>
<div class="boxItem" id="sixth">
<p>6</p>
</div>
</div>
</div>
</body>
</html>
The CSS styles are as follows:
> ...
(presented in a more readable format)
...
If achieving this layout with the current CSS structure is not possible, is there an alternative method to accomplish this utilizing just one flexbox?
You can also find this project on CodePen for reference: https://codepen.io/johntarvis/pen/LYRYVmd?editors=1100.