HTML
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@700&family=Inter:wght@400;700&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="style.css">
<title>JS Game</title>
</head>
<body>
<header>
<h1></h1>
<p></p>
</header>
<main class="container">
<button class="container__botao" onclick="botaoConsole()">Console</button>
<button class="container__botao" onclick="botaoAlerta()">Alerta</button>
<button class="container__botao" onclick="botaoPrompt()">Prompt</button>
<button class="container__botao" onclick="botaoSoma()">Soma</button>
</main>
<script src="app.js" defer></script>
</body>
</html>
CSS
* {
box-sizing: border-box;
margin: 0;
padding: 0;
color: white;
}
body {
background: linear-gradient(#1354A5 0%, #041832 33.33%, #041832 66.67%, #01080E 100%);
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
body::before {
background-image: url("img/code.png");
background-repeat: no-repeat;
background-position: right;
content: "";
display: block;
position: absolute;
width: 100%;
height: 100%;
opacity: 0.4;
}
.container {
flex-direction: column;
margin-right: 2em;
width: 60%;
height: 80%;
display: flex;
align-items: center;
justify-content: space-around;
border-radius: 24px;
border: 1px solid #1875E8;
box-shadow: 4px 4px 20px 0px rgba(1, 8, 14, 0.15);
background-image: url("img/Ruido.png");
background-size: 100% 100%;
position: relative;
}
.container__conteudo {
display: flex;
align-items: center;
position: absolute;
bottom: 0;
}
.container__informacoes {
flex: 1;
padding: 3rem;
}
.container__botao {
border-radius: 16px;
background: linear-gradient(to right, #041832, #1354A5, #1875E8);
padding: 16px 24px;
width: 30%;
font-size: 24px;
font-weight: 700;
border: none;
margin-top: 2em;
}
.container__texto {
margin: 16px 0 16px 0;
}
.container__texto-azul {
color: #1875E8;
}
.container__input {
width: 100%;
height: 72px;
border-radius: 16px;
background-color: #FFF;
border: none;
color: #1875E8;
padding: 2rem;
font-size: 24px;
font-weight: 700;
font-family: 'Inter', sans-serif;
}
.container__botao:hover{
background: rgba(255, 255, 255, 0.185)
}
h1 {
font-family: 'Chakra Petch', sans-serif;
font-size: 72px;
padding-bottom: 3rem;
margin-right: 1em;
}
p{
font-size: 32px;
}
p,
button {
font-family: 'Inter', sans-serif;
margin: 1em 0;
}
.texto__paragrafo {
font-size: 32px;
font-weight: 400;
}
button:disabled {
background-color: gray;
}
@media screen and (max-width: 1250px){
h1, p{
margin-left: .5em;
}
p {
margin: 1em;
}
}
@media screen and (min-width: 1250px) {
h1 {
font-size: 50px;
}
.container__botao {
font-size: 16px;
}
.texto__paragrafo {
font-size: 24px;
}
.container__imagem-pessoa {
display: none;
}
.container__conteudo {
display: block;
position: inherit;
}
.container__informacoes {
padding: 1rem
}
}
JS
let titulo = document.querySelector('h1');
titulo.innerHTML = 'Hora do desafio';
let paragrafo = document.querySelector('p');
paragrafo.innerHTML = 'Escolha um botão e se divirta!';
function botaoConsole(){
console.log('O botão foi clicado!');
}
function botaoAlerta(){
alert('Eu amo JS');
}
function botaoPrompt(){
let cidade = prompt('Site um nome de cidade no Brasil?');
alert(`Estive em ${cidade} e lembrei de você`);
}
function botaoSoma(){
let valor1;
let valor2;
do{
valor1 = parseInt(prompt('Digite 2 numeros inteiros para soma \nDigite o primeiro numero: '));
valor2 = parseInt(prompt('Digite o segundo numero '));
if (isNaN(valor1) || isNaN(valor2) || !Number.isInteger(valor1) || !Number.isInteger(valor2)){
alert('Digite um numero valido');
}
} while(isNaN(valor1) || isNaN(valor2) || !Number.isInteger(valor1) || !Number.isInteger(valor2));
let soma=valor1+valor2;
alert(`O valor da soma de ${valor1} + ${valor2} = ${soma}`);
}