How do I align a <ul> vertically?

Asked

Viewed 35 times

-2

I’m trying to make a website and wanted to align a <ul> vertically. align items does not work but Justify content does

<main>
  <nav>
    <ul class="nav-list">
      <li class="nav-li"><a class="nav-link" href="#">Home</a></li>
      <li class="nav-li"><a class="nav-link" href="#">About us</a></li>
      <li class="nav-li"><a class="nav-link" href="#">Products</a></li>
      <li class="nav-li"><a class="nav-link" href="#">Shopping cart</a></li>
    </ul>
  </nav>
</main>

  • 1

    Where’s your CSS? Using some framework? You have to give more details on your friend question

2 answers

0

Hello, given! I suppose you’re writing a pure css ''.

Here’s how to do it very simply.

<style>
  ul.nav-list li.nav-li{
    display: block;
    float: left;

    width: 25%;
  }
</style>

inserir a descrição da imagem aqui

And if you want to go a little deeper and already see about good practices. Here’s a link.

0

Or else:

 <style>
  li{
      display: inline;
  }
  </style>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.