I am trying to create a flexbox grid that wraps when the content exceeds the width. For this I use flexbox wrap. The problem is that the content is not aligned properly, because all words do not contain the same number of characters.
I am trying to achieve this design, it seems simple at first glance:

My best attempt:

My code is:
.bg { width: 990px; padding: 124px; height: auto; border-radius: 6px; background-color: #fff; box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.5); } .flexgrid { width: 100%; display: flex; flex-wrap: wrap; margin: 0 auto; word-wrap: break-word; } .wrap { display: flex; flex-direction: column; text-align: center; border-top: 1px solid black; padding: 33px; flex: 1; flex-basis: auto; } return ( <div className={classes.container}> <div className={classes.bg}> <h1>My Flashcards</h1> <br /> <div className={classes.flashcardcontainer}> <div className={classes.flexgrid}> {decks.map((deck, index) => { return ( <FlashcardDeck label={deck.label} lastItem={decks.length === index + 1} key={index} /> ); })} </div> </div> </div> </div> ); } } const flashCardDeck = props => { return ( <div className={classes.wrap}> <img src={deckImage} /> <p>{props.label}</p> </div> ); };
source share