I know this question has probably been asked before, but I've searched high and low and can't seem to find an answer. It seems like my front-end skills are lacking when it comes to searching for solutions.
Apologies in advance if this is a redundant post.
My issue is that I have a container that is 980 pixels wide, and I want to fill it with smaller divs that are 180 pixels wide. I have 7 smaller divs in total, so ideally, I would like 2 rows with 20 pixels between each div. The first row should have 5 divs, and the second should have 2.
I've tried floating the divs left and adding a margin, but this results in the total width exceeding 980 pixels, causing the layout to break.
I attempted setting a negative right margin on the container, but that didn't yield the desired result.
Any help or links to resources would be greatly appreciated!
EDIT: I should clarify that the container will be resizable, so the smaller divs should adapt to fill the available space, with the first div starting at 0px from the left and the last div ending at 0px from the right. The divs in between should adjust accordingly. I've only come across solutions for single-row layouts, so any advice on multi-row layouts would be helpful. Additionally, it would be ideal if the layout automatically wrapped to the next line if the margins between the smaller divs are less than 1 pixel.
EDIT 2: I've created a jsfiddle to illustrate my issue. The goal is for the green boxes to autofill the gray area horizontally, with a set vertical margin (e.g., 15/20 px).