I
I
Ilfar Khuzin2017-08-28 08:42:50
css
Ilfar Khuzin, 2017-08-28 08:42:50

How to center an element on the cross axis on hover (flexbox)?

Horizontal site menu. It is necessary to describe the hover behavior.

Initial view:
db82c31037d745c68f73f91a2ba735d9.png
On hover:
8d2f62d334bc485f828bf35901919bda.png

Links need to be centered on the vertical axis.
CSS code:
/* Menu Styles */
.menu {
  background: #313030;
  height: 12vh;
  display: flex;
  justify-content: space-around;
}

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  text-transform: uppercase;
  display: inline-block;
  margin-right: 2vh;
  padding-left: 3vh;
  padding-right: 3vh;
}

li:hover {
  background: #ff3f40;
  height: 12vh;
  margin-right: 2vh;
  padding-left: 3vh;
  padding-right: 3vh;
}

a {
  color: #e0e0e0;
}

a:hover {
  text-decoration: none;
  color: #e0e0e0;
}

nav {
  display: flex;
  align-items: center;
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
A person from Kazakhstan, 2017-08-28
@lil_comeback

you add height not to hover but to default and with hover change only background or make padding height li

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question