Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS What is the best way to arrange a responsive catalog grid?

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #161147
    Krish1980
    Participant

    I’m trying to create a catalog page, and I’d like to create a grid 4-column wide, which later on becomes 2, and eventually 1. Now, had the content been uniform, it would have been easy (for example images of the same size). I could have simply used percentages such as 25%, 50%, and then 100% for the column widths at the desired breakpoints. However, below the images would be the product names, some of which could spill into two lines. In this case, just floating the containers and setting the percentages won’t work since a longer product name would break the design.

    I’ve created a pen, which works, but seems very clunky and has additional divs.

    example

    I was wondering if there was a cleaner, more efficient way of doing this, without the use of span-2 (in the example), and perhaps just a single row wrapper for the product blocks(span-4s).

    #161155
    Paulie_D
    Moderator

    Use display:table-cell?

    http://codepen.io/Paulie-D/pen/uwixd

    You still need to use ‘rows’ but you’d need to do that anyway.

    #161185
    Paulie_D
    Moderator

    The only reason why I created span-2 was to make the layout two column at 600px width, and then later 1 column at 400px. I was wondering if there was an alternative method.

    If you need specific widths you can still do that using classes, I was solving your text-overflow issue (also the equal heights you would need).

    I’m sure there are alternate solutions, flexbox for one, but they will depend on what browsers you want to support. and whether you want to use JS/JQ.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘CSS’ is closed to new topics and replies.