V
V
Valentin Fetisov2017-01-26 11:28:39
css
Valentin Fetisov, 2017-01-26 11:28:39

How to properly lay out such a menu on flexbox?

Good afternoon. There is a task to make up such a menu using flexbox.
ffbb7d135f3e47519fc5a185675773ac.JPG
Here is a piece of code:

<menu class="flex2">
    <li><a href="#">Главная</a></li>
    <li><a href="#">Об Игре</a></li>
    <li><a href="#">Список Серверов</a></li>
    <li><a href="#">Наша Команда</a></li>
    <li><a href="#">Донат</a></li>
     </menu>

and styles:
.flex2{
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: space-between;
}
.flex2 li {
  border-left: 1px solid #247634;
  border-right: 1px solid #57e974;
  flex-basis: auto;
  flex-grow: 1;
}

but the result is like this:
5ccb32a253a64c63b11bfbf51a5d3a7f.JPG
How to make menu items the same size?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sergey Goryachev, 2017-01-26
@valentikus

Give them the same size in %, apparently width: 20%, and padding for the overall block.
https://jsfiddle.net/webirus/o1uqm8b9/
And if you want everything to be Feng Shui, then use flex-basis: 20%.
https://jsfiddle.net/webirus/o1uqm8b9/1/

Y
Yuri Oliyarnyk, 2017-01-26
@FoxPro111

set for li-niks width: 100%;

W
WQP, 2017-01-26
@WQP

For LI, you need to set flex: 1
codepen.io/Glaswr/pen/vgeKVE

E
Egor Zhivagin, 2017-01-26
@Krasnodar_etc

Set flex2 to a fixed height and li to a fixed width

D
DTX, 2017-01-26
@DirecTwiX

flex-basis: 1px
codepen.io/anon/pen/BpwzqQ

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question