Grow your CSS skills. Land your dream job.

Close HTML tags within loop on an uneven number?

  • # April 14, 2013 at 11:05 pm

    Hi everyone,

    I was wondering if someone could help me find a solution to this problem? I am using a loop to output blog posts. These posts are being set up in a two column layout. So I start a row when the count is 1, I list two posts, and then I close the row when the count is two.

    The problem I ran into was if the row only had 1 post in it. It doesn’t close the row properly. I’m trying to figure out how to close the row if there’s only 1 post without causing a problem when there’s two posts?

    Thanks!

    # April 15, 2013 at 2:59 am

    Using inline-blocks or float would definitely solve your problem. Is there any specific reason you’re using table formating?

    # April 15, 2013 at 10:32 am

    I am using a grid system with rows and columns of divs (no tables). I believe I have found a solution. At the end of the loop I can close the tags by checking if the modulus equals zero or not. Thanks!

    # April 15, 2013 at 10:37 am

    ahhh, `%`.

    : )

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

You must be logged in to reply to this topic.

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