-1
I had to use flexbox to leave the class logo
and class menu
vertically aligned in the center of the tag nav
because font-awesome icons were not working with line-height, however this is causing me problems to build the open menu, need the icone menu
stay on the right side and not on the left side.
HTML
<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>
<a class="logo" href="#">VM</a>
<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>
CSS:
* {
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;
height: 64px;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
background-color: var(--fundo-preto);
box-sizing: border-box;
}
.logo {
margin: 16px;
}
.menu {
margin: 16px;
display: none;
cursor: pointer;
color: var(--texto-branco);
}
ul {
display: flex;
}
li {
padding: 0 16px;
transition: 0.3s;
text-align: center;
}
li:hover {
background-color: var(--fundo-azul);
}
a {
text-decoration: none;
color: var(--texto-branco);
}
@media (max-width: 480px) {
.menu {
display: block;
justify-self: right;
}
/* ---MENU FECHADO--- */
/*li:not(:last-child) {
display: none;
}*/
/* ---MENU ABERTO--- */
.logo {
display: none;
}
ul {
margin-top: 160px;
position: absolute;
width: 100%;
display: block;
}
ul li{
background-color: var(--fundo-preto);
}
}