Can we arrange the subcategories like this?

AI-generated summary

In a discussion titled ‘Can we arrange the subcategories like this?’ under the Dev category and tagged with CSS, ogulcan1787 seeks to improve the layout of subcategories using display: flex, sharing screenshots of current and desired layouts. bartv praises the proposed design. ogulcan1787 later shares a partial solution using flexbox but notes issues with long subcategory names breaking the layout. Alteras suggests switching to CSS Grid with grid-template-columns: repeat(auto-fill, minmax(125px, min-content)) for better responsiveness. ogulcan1787 confirms this improves the layout and thanks Alteras. saurabhmithal asks how to implement this CSS in their community theme. ogulcan1787 and Arkshine guide them to add the CSS via Admin → Customize → Install → Edit CSS/HTML, attaching the component to their theme. saurabhmithal thanks Arkshine for the clear instructions. The thread concludes with a practical, grid-based CSS solution for responsive subcategory layouts.

Hi helpful friends.

This is how I use it now. display : flex

Can we do it like this?

But not like that. display : block

Thank you :pray:

That looks SO much better :star_struck:

I found the solution this way.
But when the subcategory name is long, it breaks.
I’m waiting if anyone can find a solution to this.
You can use it in this state. :slight_smile:

When long name.

When short name.

.category-list .subcategories {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}
.category-list .subcategories .subcategory {
    flex-shrink: 0;
    min-width: 25%;
}

You’ll want to use CSS Grids here.

Something like:

.category-list .subcategories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, min-content));
}

If you want the columns to be perfectly equal size, you can change min-content to 1fr.

Now this is much better. Thank you @Alteras :pray:

how can I add this to the theme in my community.

can someone help?

thanks.


Here in CSS write and save

As ogulcan1787 stated, you can create a new component and insert the CSS there.

You can follow these instructions:

thank you @Arkshine

this was helpful.