Forums

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

Home Forums CSS Laying out a two-column index with — flexbox?

  • This topic is empty.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #256416
    Linda_A
    Participant

    What is the best approach for laying out a two-column index where you may have an image to the left (but sometimes there isn’t one) and the text can be of varying lengths. So far, I have used standard floating and it doesn’t handle larger monitors or the missing images very well. Is flexbox an approach, for example?

    The current page is viewable at http://www.westeros.org/GoT/Episodes/ — I also added the current code into a codepen, but I think it probably needs a pretty significant retooling since it isn’t so much that this code is incorrect but rather not sufficient for the task:

    https://codepen.io/Linda_A/pen/eRrZNj

    #256421
    Paulie_D
    Member

    Unfortunately your Codepen isn’t actually showing us the problem.

    I assume you are referring to the center column in the linked page though..

    What is not clear is “What do you want this to look like… when there is an image and when there isn’t.”

    What alignment did you have in mind?.

    Will all images be the same size?

    Quite honestly, there’s nothing wrong with using an actual table here…that’s what you have after all…a table of episodes.

    If you’re violently opposed to actual tables, then CSS Table properties could be using as an alternative.

    #256439
    Linda_A
    Participant

    Sorry, it seemed like it would be confusing to include the whole page around it, so I left it to the tags being used for the actual index. But yes, its the center column.

    You are right that it is a table, I just haven’t used one in ages so I was concerned about its responsiveness. The ideal scenario is that the space reserved for the image (all images will be the same size) should remain reserved even when there’s no image, so that the text is pushed over that distance to the right.

    I’ll look at the CSS tables, thank you. :)

    #256647
    Linda_A
    Participant

    I’ve been poking at this during the week but not found any good examples to work from. If you have any resources to suggest for css tables, that would be much appreciated. I am particularly uncertain about how it would work in terms of responsiveness, as the result needs to work on both desktop and mobile.

    #256652
    Paulie_D
    Member

    Here.

    One with an actual table…the second is with CSS Tables…almost no difference as you can see.

    The structure is essentially the same except you use divs instead of table/tr/td…you just declare their display property as to how you want them to act.

    https://codepen.io/Paulie-D/pen/WOaoYw

    #256656
    Linda_A
    Participant

    Thank you! That gives me a great base to work from. With this sort of layout, is it possible to drop the text field once I get below a certain size, to have it just be the cell with the image?

    #256660
    Paulie_D
    Member

    You can hide them if you want using media queries but not drop them unless you’re loading the content dynamically server-side.

    #256674
    Linda_A
    Participant

    Alright, that’s how I will approach it then, if necessary. Thank you again.

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