1

I have a menu (ul tags) whose elements are inline. Right now, the elements wrap when they reach the width of the container:

Right now

This is what I would like is to force the menu to be on two lines:

Goal

If extra entries are added, I would like the menu to equally divide on the two lines:

behavior

I'm ideally looking for a way to do it with css only. I tried using flexbox and writing-direction without succes. I'm open to a javascript solution but would like to have soft enought solution to allow for different designs in other responsive modes.

Edit:

Here is my HTML:

<ul class="main-menu">
  <li class="main-menu__entry"><a href="#">Le projet</a></li>
  <li class="main-menu__entry"><a href="#">Les numéros</a></li>
  <li class="main-menu__entry"><a href="#">Obtenir le magazine</a></li>
  <li class="main-menu__entry"><a href="#">Devenir coopérateur</a></li>
  <li class="main-menu__entry"><a href="#">Nous contacter</a></li>
  <li class="main-menu__entry"><a href="#">Proposer un sujet</a></li>
</ul>

and CSS (I simplified wit honly the relevant code)

.main-menu__entry {
  display: inline-block;
  padding: 4px 8px;
  border: 2px solid gold;
  margin: 0 2px 2px 0;
  color: black;
}

Thanks.

user1415785
  • 342
  • 4
  • 13

1 Answers1

0

Is this what you are looking for? This is definitely a scalable solution, but should be useful for now.

.main-menu__entry {
  display: inline-block;
  padding: 4px 8px;
  border: 2px solid gold;
  margin: 0 2px 2px 0;
  color: black;
  width: 150px;
}
<ul class="main-menu">
  <li class="main-menu__entry"><a href="#">Le projet</a></li>
  <li class="main-menu__entry"><a href="#">Les numéros</a></li>
  <li class="main-menu__entry"><a href="#">Obtenir le magazine</a></li>
  <li class="main-menu__entry"><a href="#">Devenir coopérateur</a></li>
  <li class="main-menu__entry"><a href="#">Nous contacter</a></li>
  <li class="main-menu__entry"><a href="#">Proposer un sujet</a></li>
</ul>
Ishwar Patil
  • 1,671
  • 3
  • 11
  • 19