I've created an image gallery with a 2-column layout, allowing for full-width images to be interspersed between the columns.
To see an example of this, check out my Codepen:
<div class="gallery">
<img src="http://nosrc.io/200x200">
<img src="http://nosrc.io/200x200">
<img class="large" src="http://nosrc.io/400x200">
<img src="http://nosrc.io/200x200">
<img src="http://nosrc.io/200x200">
<img src="http://nosrc.io/200x200">
<img src="http://nosrc.io/200x200">
<img class="large" src="http://nosrc.io/400x200">
<img src="http://nosrc.io/200x200">
<img src="http://nosrc.io/200x200">
<img src="http://nosrc.io/200x200">
<img src="http://nosrc.io/200x200">
</div>
Click here to view the Codepen
My issue is that when using :nth-child
, it selects the wrong items in the gallery after the second full-width image. Ideally, all left column images should have margin-left: 0;
and all right column images should have margin-left: 2%;
.
P.S. Unfortunately, I am unable to utilize JavaScript for this project.