Dia 24/2019 - Formulário simples

Desafio #92daysofcode que fiz no final de 2019. Nesse artigo temos o dia 24, mostrando o uso de um formulário e a pseudo-classe CSS :nth-child.

Pré-visualização

Código

Começamos com a estrutura do HTML.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Day 24</title>
<style>
*, *:before, *:after { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing:border-box; }
html { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; box-sizing:border-box; }
* { margin: 0; padding: 0; list-style: none; outline: none; }
body { background: #4b1f71; font-family: Arial, Helvetica, sans-serif; }
.container { align-items: center; display: flex; flex-flow: row nowrap; height: 100%; justify-content: center; padding: 10px; width: 100%; }
</style>
<link rel="stylesheet" type="text/css" href="./day-24.css">
</head>
<body>
<div class="container">
<!-- form -->
</div>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<form class="form">
<div class="form-group" tabindex="1">
<label class="form-label" for="username">Nome</label>
<input class="form-field" name="username" type="text" autocomplete="off" placeholder="ex: João Lemos" required>
</div>
<div class="form-group" tabindex="2">
<label class="form-label" for="email">Email</label>
<input class="form-field" name="email" type="text" autocomplete="off" placeholder="email@provedor.com" required>
</div>
<div class="form-group" tabindex="3">
<label class="form-label" for="message">Mensagem</label>
<textarea class="form-field--textarea" name="message" placeholder="Escreva aqui" required></textarea>
</div>
<div class="form-actions">
<!-- <button class="form-actions-submit" type="submit">Enviar</button> -->
<button class="form-actions-submit" type="reset">Enviar</button>
</div>
</form>
<ul class="bg">
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
<li class="bg-item"></li>
</ul>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
.form { align-items: center; display: flex; flex-flow: column wrap; justify-content: center; width: 100%; z-index: 1; }

@media (min-width: 480px) {
.form { width: 480px; }
}

.form-group,
.form-label,
.form-field,
.form-field--textarea { width: 100%; }

.form-group { margin-top: 10px; }
.form-group:first-child { margin-top: 0; }

.form-field,
.form-field--textarea { font-size: 1rem; outline: none; padding: 5px 10px; transition: all 0.5s ease; }

.form-label { color: #fff; display: block; margin-bottom: 5px; }

.form-group:focus-within .form-label { color: #ffee96; }

.form-field,
.form-field--textarea {
background: #fff;
border: none;
border-radius: 4px;
box-shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.4);
font-size: 1rem;
}

.form-field--textarea { height: 110px; }

.form-field:focus,
.form-field--textarea:focus { background: #340d5d; color: #fff; box-shadow: none; }

.form-field--textarea { resize: none; }

.form-actions-submit {
background: #4b1f71;
border: none;
border-radius: 4px;
box-shadow: 0 8px 6px -6px rgba(0, 0, 0, 0.4);
color: #fff;
cursor: pointer;
font-size: 1rem;
margin: 16px 0 50px 0;
padding: 8px 16px;
transition: all 0.5s ease;
text-transform: uppercase;
}

.form-actions-submit:hover { background: #340d5d; box-shadow: none; letter-spacing: 2px; }


.bg { height: 100%; position: absolute; top: 0; left: 0; width: 100%; }

.bg-item {
animation: _spin 20s infinite;
border-right: 0.4rem solid transparent;
border-bottom: 1.2rem solid #673196;
border-left: 0.4rem solid transparent;
display: block;
height: 0;
position: absolute;
bottom: -80px;
transition-timing-function: linear;
width: 0;
}

.bg-item:before,
.bg-item:after {
border-right: 1.4rem solid transparent;
border-bottom: 1.2rem solid #673196;
border-left: 1.4rem solid transparent;
content: '';
display: block;
height: 0;
position: absolute;
top: 1rem;
left: -1.3rem;
transform: rotate(-35deg);
width: 0;
}

.bg-item:after { transform: rotate(35deg); }

.bg-item:nth-child(1) { left: 10%; }
.bg-item:nth-child(2) { animation-delay: 2s; animation-duration: 17s; left: 20%; }
.bg-item:nth-child(3) { animation-delay: 4s; left: 25%; }
.bg-item:nth-child(4) { animation-duration: 14s; left: 40%; }
.bg-item:nth-child(5) { left: 70%; }
.bg-item:nth-child(6) { animation-delay: 3s; left: 80%; }
.bg-item:nth-child(7) { animation-delay: 7s; left: 32%; }
.bg-item:nth-child(8) { animation-delay: 15s; animation-duration: 40s; left: 55%; }
.bg-item:nth-child(9) { animation-delay: 2s; animation-duration: 40s; left: 75%; }
.bg-item:nth-child(10) { animation-delay: 11s; left: 90%; }

@keyframes _spin {
0% { transform: translateY(0); }
100% { transform: translateY(-700px) rotate(600deg); }
}

Conclusão

A postagem original pode ser vista no meu Instagram e o código está acessível no meu Github.

Ao fechar este aviso ou continuar navegando no site Nerd Calistênico, você aceita o uso de cookies.

Este site usa cookies para assegurar a melhor experiência para os nossos usuários. Consulte nossa política de privacidade.

Uma nova versão está disponível. Clique aqui para atualizar.