Flexbox not giving equal width to elements

前端 未结 2 1171
攒了一身酷
攒了一身酷 2020-11-28 00:28

Attempting a flexbox nav that has up to 5 items and as little as 3, but it\'s not dividing the width equally between all the elements.

Fiddle

The tutorial

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 01:11

    To create elements with equal width using Flex, you should set to your's child (flex elements):

    flex-basis: 25%;
    flex-grow: 0;
    

    It will give to all elements in row 25% width. They will not grow and go one by one.

提交回复
热议问题