You will encounter this problem with floats. However, you can change the location of one element on this page, and everything will fall as you expect.
Updated script
Add the following to your CSS:
#homepage-grid li#tile10 { position: absolute; top: 342px; }
This violates the violating element from the document flow, thereby eliminating the vertical space reservation that is assigned to it by the "float" applied to the rest of the list items. The last element floats to the right, so it will not overlap an absolutely positioned tile.
EDIT
In the comments below, here is a slightly more flexible way to do this . An example works for published code.
Assumptions made with the updated fiddle:
- sizex1, sizey1, sizex2 etc. are constant values
- That the content to the right of them will be placed to the right (this will work in the reverse order for the left movable elements, but these scripts look as if they would not be a problem, since the elements on the right will float correctly if the elements on the left are larger vertically)
- The user has the ability to redefine styles or apply styles when creating a layout. This is primarily for controlling
position: absolute from unnecessarily applying to certain elements.
What does it do:
This CSS sets up different rules based on the existence of siblings with specific classes. Therefore, the constancy of the values ββof sizex1 sizex2 sizey1 and sizey2 .
CSS:
#homepage-grid li.col1:not(.row1):not(.row2) { position: absolute; } #homepage-grid li.col1.sizey1.row1 ~ li.col1.row2 { top: 172px; } #homepage-grid li.col1.sizey2.row1 ~ li.col1.row2{ top: 342px; } #homepage-grid li.col1.sizey1.row1 ~ li.col1.sizey1.row2 ~ li.col1.row3 { top: 344px; } #homepage-grid li.col1.sizey2.row1 ~ li.col1.sizey2.row2 ~ li.col1.row3{ top: 684px; } #homepage-grid li.col1.sizey2.row1 ~ li.col1.sizey1.row2 ~ li.col1.row3, #homepage-grid li.col1.sizey1.row1 ~ li.col1.sizey2.row2 ~ li.col1.row3 { top: 514px; }
Ideally, you want to set #homepage_grid li.col1 to the delivery of the page. This way, you can choose which tiles are broken from the document stream to maintain the correct spacing. I usually do this with the :not() selector, but if you're looking for older browser compatibility, you can just as easily use overriding.
Example:
#homepage-grid li.col1:not(.row1):not(.row2) { position: absolute; }
* The above will result in line breaks of 3 or more from the document stream.
#homepage-grid li.col1 { position: absolute; } #homepage-grid li.col1.row1, #homepage-grid li.col1.row2 { position: static; }
This does the same as above, but in more detail. However, it will display accordingly in less standardized browsers.
EDIT 2 For simplicity, here is an example of using jQuery to set the corresponding elements as static when the page loads.
Another example of a violin