How to set a fixed width column with CSS flexbox?

Spread the love

Sometimes, we want to set a fixed width column with CSS flexbox.

In this article, we’ll look at how to set a fixed width column with CSS flexbox.

How to set a fixed width column with CSS flexbox?

To set a fixed width column with CSS flexbox, we use the flex-basis style.

For instance, we write

.flexbox .red {
  flex: 0 0 25em;
}

to set the width of the element with class red in the element with class flexbox to 25em.

25em is the flex-basis value.

We disable flex grow and flex shrink respectively with the first 2 numbers.

Conclusion

To set a fixed width column with CSS flexbox, we use the flex-basis style.

Leave a Reply

Your email address will not be published. Required fields are marked *