I'm a bit smitten with my grid layout in CSS. I have a wrapper (1000px wide) and want to put divs with float:left;
and a margin from 23px between each. This would be easily achievable using the :nth-child
selector. But now I have a text block in the left top corner whose height is variable and the number of grid items is variable too.
So I set the right-margin
of the text block and the grid items to 23px. But when the most right grid element has 23px right-margin
, it breaks to the next line.
I cannot use nth-child
here because I do not know, how many rows of two items and how many of three items I will get.
I hope there is a CSS-only solution for my problem.
UPDATE
Here is a Fiddle which shows the attempts I made: jsfiddle.net
Here is my layout how it should be:
+-------------------------------------------+
|+---------------+ +----------+ +----------+|
|| | | | | ||
|| | | | | ||
|| | | | | ||
|| | +----------+ +----------+|
|| Textblock | +----------+ +----------+|
|| | | | | ||
|| | | | | ||
|| | | | | ||
|+---------------+ +----------+ +----------+|
|+----------+ ^ ^ ^|
|| | (margin) (margin) (no margin)
|| | |
|| | |
|+----------+ |
+-------------------------------------------+
^
(no margin)