Site logo

[Resolved] List Subcategory Code / CSS

Home Forums Support [Resolved] List Subcategory Code / CSS

Home Forums Support List Subcategory Code / CSS

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2492594
    Scott

    Hello! i implemented the code here (https://generatepress.com/forums/topic/show-list-sub-category-in-category-page/) to show sub categories on my category page. Used this CSS to style as buttons:

    .gb-container .list-subcats {list-style:none; display:flex;justify-content:space-around}
    .gb-container .list-subcats li a {color:#607e26;background-color:#fffcec;padding:10px 25px; border:1px #71942c solid; border-radius:25px;}
    @media (max-width:800px) {.gb-container .list-subcats {flex-direction:column;text-align:center;}}
    @media (max-width:800px) {.gb-container .list-subcats li{flex-direction:column;text-align:center;margin:15px 20px}}

    Is there a way to limit the number of flex columns? Buttons are getting split in two on the category pages with more than four subcategories. I want to limit it to 4 per line (4 columns per line on desktop)?
    Link and example photo below.

    THANKS!

    #2492831
    David
    Staff
    Customer Support

    Hi there,

    look for this CSS:

    .gb-container .list-subcats {
        list-style: none;
        display: flex;
        justify-content: space-around;
    }

    and replace it with:

    .gb-container .list-subcats {
        list-style: none;
        display: flex;
        flex-wrap: wrap;
    }

    This will make flex wrap so it creates extra rows when it runs out of space.

    Then add this CSS if to put some space between them:

    .gb-container .list-subcats li {
        display: block;
        margin: 20px 5px;
    }
    #2493020
    Scott

    Much better – how can I center the entire container? tried the tricks I knew – none of which worked. THANKS!

    #2493144
    David
    Staff
    Customer Support

    Try adding justify-content: center; to this CSS:

    .gb-container .list-subcats {
        list-style: none;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }
    #2496132
    Scott

    Perfect – thanks

    #2496154
    David
    Staff
    Customer Support

    You’re welcome

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.