Grow your CSS skills. Land your dream job.

Modified Don’t Overthink It Grids and Styling

  • # January 12, 2013 at 10:48 am

    Recently, I’ve been using Chris Coyier’s [Don't Overthink It Grids]( “”) as my grid template, as shown [here]( “”). Unfortunately, this approach actually doesn’t produce the correct widths. As shown in my example, the left column is narrower than the right (the squares’ heights/widths are the same ration, thus if the left is shorter, then the left column is narrower).

    This is remedied with [Matt Berridge's fix]( “″) as show [here]( “”), but this fix introduces another problem. In the fix, the grid is positioned using a negative left margin, with the first column’s left padding pushing back into place. This means that any styling applied to the grid(such as borders or backgrounds) show this extra padding on the left.

    Is there any way to correctly position the grid without showing the padding on the left, while maintaining the correct widths? Or, is there any way to hide (?) the left padding of the first column?

    # January 12, 2013 at 11:06 am

    It’s the padding right on the last-of-type that’s causing the problem.

    I assume you added the padding to the others?

    # January 12, 2013 at 11:34 pm

    Thanks for the input, Andy. I understand that in the first grid it’s the lack of padding on the final element that’s causing the element to be wider.

    In the second grid, however, this is fixed by putting the padding on the left of the elements, then moving the entire grid left using a negative margin. The problem with this (and the problem that I’m grappling with at the moment) is that by using the negative margin and left padding together, I’m not able to effectively apply any styles. Any backgrounds or borders I place on the grid or columns shows the extra padding which is effectively outside of the grid.

    Sorry if my first post (or this post) is unclear.

    # January 23, 2013 at 11:00 am

    I’m having the same problem right now. Any solution on this so far?

    The solution of [Matt Berridge]( did not work for me because the negative margin on .grid makes its parent element .page-wrap wider to the left. And therefore the whole thing would not centered on the page anymore but instead slightly moved to the left.

    I created a quick [codepen]( with my grid. I use Chris Coyiers solution for the gutters with a padding-right. And the last column gets padding: 0.

    The only problem apart from browser support (IE 8 can’t use that, right?) occurs when I would want to insert e.g. more than two 50% columns to create multiple lines.
    Because then only the last item of those would get the appropriate padding:0.
    I would have to wrap every few elements that add up to 100% (so every line of columns) in a .grid.

    # January 23, 2013 at 11:54 am

    Unfortunately, the only way that I could solve the problem was to put the whole grid in a container div, which is probably not the most semantic way to go about it. I put one together [here]( “”) to show you what I mean. By using a containing div, you can give the whole grid external padding, with precisely equal columns, give it a background without showing the negative left margin and give it borders etc.

    I’m still looking for better grid systems out there.

    # January 23, 2013 at 12:19 pm

    @David_Leitch Where would you apply your .grid-pad class then? I tried on both .container and .grid but in each case I got the result that the right column is smaller than the other because it gets padding right and left.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".