HTML
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Manipulando o DOM - Aula 3</title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
<button id="botao">Estoque <i>Aluratintas</i></button>
<ul class="lista">
<li cor="laranja" tipo="tinta-exterior" class="item">Tinta laranja</li>
<li cor="vermelho" tipo="tinta-interior" class="item">Tinta vermelha</li>
<li cor="branco" tipo="tinta-interior" class="item">Tinta branca</li>
<li cor="amarelo" tipo="tinta-exterior" class="item">Tinta amarela</li>
<li cor="rosa" tipo="tinta-exterior" class="item">Tinta rosa</li>
<li cor="preto" tipo="tinta-exterior" class="item">Tinta preta</li>
</ul>
<button class="close">Fechar</button>
<a href="https://alura.com.br/" target="_blank"><img src="https://www.alura.com.br/assets/img/home/alura-logo.svg" alt="" class="alura-logo"></a>
<script src="main.js"></script>
</body>
</html>
CSS
* {
margin: 0;
padding: 0;
}
body {
font-family: "Roboto Mono", monospace;
min-height: 400px;
min-width: 450px;
background-size: 80vh;
color: rgb(0, 0, 0);
background-image: url("https://www.uniabeu.edu.br/wp-content/uploads/2020/03/fundo-lilas.png");
background-size: cover;
background-repeat: no-repeat;
height: 100vh;
font-size: 24px;
font-weight: bold;
display: flex;
align-items: center;
flex-direction: column;
}
button {
font-size: 24px;
font-family: "Futura Lt BT", sans-serif;
background-color: black;
background-repeat: no-repeat;
cursor: pointer;
overflow: hidden;
outline: none;
padding: 8px 20px 8px 20px;
color: white;
box-shadow: 0px 0px 5px gray;
border-radius: 3px;
border: none;
transition: 500ms;
opacity: 0.8;
margin: 30px 0;
}
button:hover {
color: white;
background-color: gray;
}
button:active {
color: black;
background-color: white;
}
.lista {
display: none;
padding: 20px;
list-style-type: none;
border: 4mm ridge rgba(234, 122, 11, 0.992);
}
.alura-logo {
width: 150px;
position: absolute;
top: 2%;
right: 2%;
}
[cor="laranja"] {
color: orange;
}
[cor="vermelho"] {
color: red;
}
[cor="branco"] {
color: white;
}
[cor="amarelo"] {
color: yellow;
}
[cor="rosa"] {
color: pink;
}
[cor="preto"] {
color: black;
}
JS
const lista = document.querySelector('.lista')
const estoque = document.querySelector('#botao')
const fechar = document.querySelector('.close')
estoque.addEventListener("click", (evento) => {
lista.style.display = 'block';
})
fechar.addEventListener("click", (evento) => {
lista.style.display = 'none';
})