vincent15000's avatar

flex-wrap : add an additional class to even rows

Hello,

How is it possible to add an additional class to even rowns if I use flex with flex wrap to display divs ?

Thanks for your help.

V

0 likes
6 replies
MohamedTammam's avatar
Level 51

You need to specify the width for each element, otherwise you can't just control the number of elements for each row.

However, if you add to the elements flex-grow: 1; All rows are going to be filled. But you still with the first issue.

Is this what you're asking for?

1 like
vincent15000's avatar

@MohamedTammam I want to display hexagonal divs like a beehive. Even rows need a margin left to do that.

The problem is : how to add a class only to the divs that are in the even rows.

I also thought about doing this with a CSS grid, but I think that the problem is the same.

vincent15000's avatar

@Snapey Yes thank you ... but if I'm using CSS flex or CSS grid, I don't any divs to display the different rows, it's a unique div and the rows are created automatically.

Or perhaps I think too complicated and I don't think about something very simple ?

Snapey's avatar

@vincent15000 perhaps you need a grid of a single row, followed by a grid of a single row

I cant see how a grid with multiple rows can be staggered left and right?

1 like

Please or to participate in this conversation.