-2
I would like the Font Awesome icon to be aligned vertically in the center of the div <nav>
, same as class item logo
on a screen smaller than 480px. I tried with line-height
, but it didn’t work out like the other.
Code:
* {
padding: 0;
margin: 0;
font-family: 'Open Sans', sans-serif;
}
:root {
--texto-branco: #f2f2f2;
--fundo-preto:#262626;
--fundo-azul:#009DFF;
}
nav {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 64px;
padding: 0 10%;
background: var(--fundo-preto);
box-sizing: border-box;
}
.logo {
float: left;
line-height: 64px;
color: var(--texto-branco);
}
.menu {
color: var(--texto-branco);
cursor: pointer;
float: right;
display: none;
}
ul {
text-align: right;
display: block;
}
li {
display: inline-block;
padding: 0 16px;
list-style: none;
}
li:hover {
background: var(--fundo-azul);
}
a {
color: var(--texto-branco);
line-height: 64px;
text-decoration: none;
}
@media (max-width: 480px) {
.menu {
display: block;
}
ul {
display: none;
}
}
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<script src="https://kit.fontawesome.com/a3703589d3.js" crossorigin="anonymous"></script>
<title>VM Design</title>
</head>
<body>
<nav>
<div class="logo"><p>M</p></div>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Sobre</a></li>
<li><a href="#">Projetos</a></li>
<li><a href="#">Fale Comigo</a></li>
</ul>
<div class="menu"><i class="fas fa-bars"></i></div>
</nav>
</body>
</html>
It has to line up without using flex-box, because when I go to make the menu open for mobile align-items would not cause me problems?
– Vinicius Macedo
Why would it? I don’t think so.
– Luiz Felipe
When I change ul { display: None } to { display:block} it will align these items vetically as well, when they need to be something like flex-start
– Vinicius Macedo