Forums

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

Home Forums CSS Multiline horizontal list

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #38148
    lorenzo
    Member

    Hello everyone!
    I am having problems with a horizontal list that needs to go on multiple lines if the container is too small. Each list item will have variable height, which is what’s causing problems…
    Here is an example:
    http://jsfiddle.net/lorenzo/HK66f/1/
    Is there anyway I can get box 4 to go below box 1, but clearing 1, 2 and 3?
    Hopefully someone can help :)
    Thanks!

    Lorenzo

    #103164
    Senff
    Participant

    I assume you want box 4 to be immediately under box 1 (and not have the top as the same height as the bottom of box 2, like this: http://jsfiddle.net/HK66f/2/ ).

    That’s not possible to do without some super clever scripts. I think you want to look into jQuery Masonry.

    #103182
    lorenzo
    Member

    Hi Senff, thanks for your answer!
    Your css does what I need, however this only works in this particular case. I don’t know how many boxes will fit on each line because it depends on window size, so I don’t know which boxes need clear:both applied…

    #103186
    mmoustafa
    Member

    Yup!! I’ve looked it up alot, and as @Senff said, jQuery Masonry was the only option.

    Don’t worry though, you don’t need much JS knowledge to implement it.

    #103187
    lorenzo
    Member

    Actually, what I am trying to achieve is similar to what Senff posted in his fiddle. Every new line should start below the tallest element of the previous line. Masonry seems to be doing some clever fitting which I don’t need :) Of course I can’t arrange elements in rows because I don’t know what the row length will be, as it depends from the window width…

    #103188
    Senff
    Participant

    So each block is a different height, but do they all have the same width? Is the container always the same width? If that’s the case, would it make sense to say that every fourth item needs to start on a new line?

    #103189
    lorenzo
    Member

    All blocks have the same width, but they have unpredictable height. Also, as I said the container width is unpredictable… I know its a mess! :(

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