How can I place the divs
in a specific place within the container without changing the HTML?
<div class="container">
<div class="item item1">Item 1</div>
<div class="item item2">Item 2</div>
<div class="item item3">Item 3</div>
<div class="item item4">Item 4</div>
</div>
Here is a diagram of the layout I’m trying to achieve:
2
Answers
I add example code below.
You can use CSS Grid to achieve this:
Here’s a little less "fragile" version, to scale with content:
If you need a gap in between elements: