A
A
Alexander2019-06-27 13:07:05
css
Alexander, 2019-06-27 13:07:05

How to center text in a listbox on Flex?

There is a horizontal menu located in a block, all on flexbox. How to make the text of "li" blocks centered vertically?
There is a margin-top, then the background also slides down, and I only need to lower the text a little lower.
I understand that it can be done faster on a div, but is there still a solution for a list?
5d1497fe1903a299919952.png

<div class="top-menu">
  <ul>
    <li><a href="/">Главная</a></li>
    <li><a href="#">Статьи</a></li>
    <li><a href="#">VST Инструменты</a></li>
    <li><a href="#">VST Плагины</a></li>
    <li><a href="#">О нас</a></li>
    <li><a href="#">Помощь проекту</a></li>
  </ul>
</div>

.top-menu {
  display: flex;
  width: 40%;
  justify-content: center;
        background: yellow;
}
.top-menu>ul {
  display: flex;
  justify-content: space-between;
  
}
.top-menu>ul>li {
  margin-right: 2.5em;
  background: gray;
  height: 100%;
}
.top-menu>ul>li>a {
  color: white;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
A person from Kazakhstan, 2019-06-27
@alterak

https://codepen.io/topicstarter/pen/agVmZK corrected a little bit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question