-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path9.html
495 lines (441 loc) · 21.5 KB
/
9.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Формы и элементы ввода</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#007BFF">
<link rel="stylesheet" href="node_modules/@shower/material/styles/styles.css">
<link rel="stylesheet" href="styles/all_styles.css">
<link rel="shortcut icon" type="image/png" href="pictures/general/narfu_icon.png">
</head>
<body class="shower list">
<header class="caption">
<h1>Формы и элементы ввода</h1>
<p><a href="index.html">Web-технологии</a></p>
</header>
<section class="slide narfu_official" id="cover">
<h2>Формы и элементы ввода</h2>
<p>Лекция №7.2</p>
</section>
<!-- Main -->
<section class="slide narfu">
<h2>Что такое веб-форма</h2>
<div class="columns two">
<p><b>Веб-формы</b> (или HTML-формы) являются одним из основных элементов взаимодействия между пользователем и
сайтом или приложением. </p>
<img src="pictures/9/google%20form.png" alt="" style="width: 300px; margin-left: 50px">
</div>
</section>
<section class="slide narfu">
<h2>Виджеты</h2>
<p>HTML-формы состоят из одного или нескольких элементов управления форм (иногда их также называют <b>виджетами</b>)
и некоторых дополнительных элементов для структурирования формы.</p>
<p>Элементами управления могут быть однострочные или многострочные текстовые поля, выпадающие списки, кнопки,
чекбоксы, радиокнопки и другие.</p>
</section>
<section class="slide narfu">
<img src="pictures/9/widgets.svg" alt="" class="cover w h">
</section>
<section class="slide narfu">
<img src="pictures/9/validation.svg" alt="" class="cover w h">
</section>
<section class="slide narfu">
<h2 class="shout"><span style="font-size: smaller">Проектирование формы</span></h2>
</section>
<section class="slide narfu">
<h2>Набросок</h2>
<div class="columns two">
<p>Создание быстрого наброска поможет определить верный набор данных, которые вы хотите получить от
пользователя.</p>
<img src="pictures/9/proecting.png" alt="" style="width: 400px">
</div>
</section>
<section class="slide clear">
<img src="pictures/9/android-kit.png" alt="" class="cover w">
</section>
<section class="slide clear">
<img src="pictures/9/ios-kit.png" alt="" class="cover w">
</section>
<section class="slide narfu">
<img src="pictures/9/form.svg" alt="" class="cover w">
</section>
<section class="slide narfu">
<h2>Верстка формы</h2>
<p>Создание форм начинается с элемента <code><form></code>:</p>
<pre>
<code><form action="/my-handling-form-page" method="post"></code>
<code class="comment"> <!-- Здесь будут элементы формы --></code>
<code></form></code>
</pre>
</section>
<section class="slide narfu">
<h2>Атрибуты <code><form></code></h2>
<ul>
<li>Атрибут <code>action</code> определяет адрес, куда должны быть посланы данные после отправки формы.</li>
<li>Атрибут <code>method</code> указывает, какой HTTP-метод будет использован при передаче данных (это может
быть <code>get</code> или <code>post</code>).
</li>
</ul>
</section>
<section class="slide narfu">
<h2>Поля контактной формы</h2>
<p>Форма состоит из трёх текстовых полей, каждое их которых связано с HTML-элементом <code><label></code>:</p>
<ol>
<li>Поле для ввода имени — это тег <code><input></code>, где в поле <code>type</code> указано
<code>text</code>;
</li>
<li>Поле для ввода e-mail — тот же тег, но в <code>type</code> будет написано <code>email</code>;</li>
<li>Поле для ввода сообщения — тег <code><textarea></code>, многострочное текстовое поле.</li>
</ol>
</section>
<section class="slide narfu">
<pre>
<code><form action="/my-handling-form-page" method="post"></code>
<code class="mark next"> <label for="name">Имя:</label></code>
<code> <input type="text" id="name"></code>
<code class="mark next"> <label for="mail">E-mail:</label></code>
<code> <input type="email" id="mail"></code>
<code class="mark next"> <label for="msg">Сообщение:</label></code>
<code> <textarea id="msg"></textarea></code>
<code></form></code>
</pre>
</section>
<section class="slide narfu">
<img src="pictures/9/text-vs-email.svg" alt="" class="cover w h">
</section>
<section class="slide narfu">
<h2>Разница текстовых полей</h2>
<p>Обратите внимание на разницу синтаксиса у HTML-элементов <code><input></code> и
<code><textarea></code>:</p>
<pre>
<code><input type="text" <mark>value="текст по умолчанию"</mark> /></code>
<code> </code>
<code><textarea></code>
<code> <mark>текст по умолчанию</mark></code>
<code></textarea></code>
</pre>
</section>
<section class="slide narfu">
<h2>Отправка данных на сервер</h2>
<pre>
<code><form></code>
<code> ...</code>
<code> <button type="submit">Отправить</button></code>
<code></form></code>
</pre>
</section>
<section class="slide">
<figure>
<img src="pictures/9/form-codepen.png" alt="" class="cover h">
<figcaption><a href="https://codepen.io/lovesolaristics/pen/ZEyqmNg?editors=1100" class="copyright"
style="margin-bottom: 40px;">Живой пример на Codepen</a></figcaption>
</figure>
</section>
<section class="slide narfu">
<h2>Типы кнопок</h2>
<p>HTML-элемент <code><button></code> принимает атрибут <code>type</code>, который может быть равен одному из
трёх значений: <code>submit</code>, <code>reset</code> или <code>button</code>:</p>
<ul>
<li><code>submit</code> - оправляет данные формы;</li>
<li><code>reset</code> - очищает все поля формы;</li>
<li><code>button</code> - не делает ничего;</li>
</ul>
</section>
<section class="slide narfu">
<h2>Добавление имен полей</h2>
<pre>
<code><form action="/my-handling-form-page" method="post"></code>
<code> <label for="name">Имя:</label></code>
<code> <input type="text" id="name" <mark>name="user_name"</mark>></code>
<code> <label for="mail">E-mail:</label></code>
<code> <input type="email" id="mail" <mark>name="user_mail"</mark>></code>
<code> <label for="msg">Сообщение:</label></code>
<code> <textarea id="msg" <mark>name="user_message"</mark>></textarea></code>
<code></form></code>
</pre>
</section>
<section class="slide narfu">
<img src="pictures/9/submit.svg" alt="" class="cover w">
</section>
<section class="slide narfu">
<h2 class="shout"><span style="font-size: smaller">Структурирование форм</span></h2>
</section>
<section class="slide narfu">
<h2>Группировка полей</h2>
<pre>
<code><form></code>
<code> <fieldset></code>
<code> <legend>Размер стакана фруктового сока</legend></code>
<code> <label for="size_1">Маленький</label></code>
<code> <input type="radio" name="size" id="size_1" value="small"></code>
<code> ...</code>
<code> </fieldset></code>
<code></form></code>
</pre>
</section>
<section class="slide narfu">
<h2>Пример</h2>
<form>
<fieldset style="border: 2px solid #007BFF;">
<legend>Размер стакана фруктового сока</legend>
<p>
<input type="radio" name="size" id="size_1" value="small">
<label for="size_1">Маленький</label>
</p>
<p>
<input type="radio" name="size" id="size_2" value="medium">
<label for="size_2">Средний</label>
</p>
<p>
<input type="radio" name="size" id="size_3" value="large">
<label for="size_3">Большой</label>
</p>
</fieldset>
<p class="copyright" style="color: #007BFF;"><a href="https://www.nvaccess.org/download/">
Экранный диктор NV Access</a></p>
</form>
</section>
<section class="slide narfu">
<h2>Подписи к полям</h2>
<pre>
<code><label for="name">Имя:</label></code>
<code><input type="text" id="name" name="user_name"></code>
</pre>
<p>Или так:</p>
<pre>
<code><label for="name"></code>
<code> Имя: <input type="text" id="name" name="user_name"></code>
<code></label></code>
</pre>
</section>
<section class="slide clear">
<figure>
<img src="pictures/9/payment-form.png" alt="" class="cover w">
<figcaption><a href="https://codepen.io/lovesolaristics/pen/wveREWy" class="copyright">Живой пример на CodePen
</a></figcaption>
</figure>
</section>
<section class="slide narfu">
<h2 class="shout">Стандартные виджеты</h2>
</section>
<section class="slide narfu">
<h2>Текстовые поля</h2>
<p>Однострочные текстовые поля создаются с использованием элемента <code><input></code> чей атрибут
<code>type</code> имеет значение <code>text</code>.</p>
<pre>
<code><input type="text" id="comment" name="comment"</code>
<code> value="Это текстовое поле"></code></code>
</pre>
</section>
<section class="slide white">
<h2>Текстовые поля</h2>
<img src="pictures/9/text-field.png" alt="" class="place">
</section>
<section class="slide narfu">
<h2>Текстовые поля</h2>
<div class="columns two">
<ul>
<li><code>text</code> - уже знакомы;</li>
<li><code>email</code> - электронная почта;</li>
<li><code>password</code> - пароль;</li>
<li><code>search</code> - поле поиска;</li>
<li><code>tel</code> - телефонный номер;</li>
<li><code>url</code> - адрес в интернете.</li>
</ul>
<form>
<ul style="">
<li><input style="padding: 5px;" required type="text" value="Простой текст"></li>
<li><input style="padding: 5px;" required type="email" value="[email protected]"></li>
<li><input style="padding: 5px;" required type="password" value="1234567890"></li>
<li><input style="padding: 5px;" required type="search" value="Как сделать ракету?"></li>
<li><input style="padding: 5px;" required type="tel" value="8-800-555-35-35"></li>
<li><input style="padding: 5px;" required type="url" value="http://en.wikipedia.org/wiki/"></li>
</ul>
<button type="submit" style="background-color: #007BFF; border: 0; color: white; padding: 10px;">
Проверить
</button>
</form>
</div>
</section>
<section class="slide narfu">
<h2>Многострочный текстовый виджет</h2>
<p>Отдельно остановимся на виджете, позволяющем ввести сразу несколько строк текста:</p>
<pre>
<code><textarea cols="30" rows="10"></code>
<code> Это многострочный текст</code>
<code></textarea></code>
</pre>
</section>
<section class="slide white">
<h2>Многострочный текстовый виджет</h2>
<img src="pictures/9/textarea.png" alt="" class="place">
</section>
<section class="slide narfu">
<h2>Drop-down виджеты</h2>
<p>Виджет, позволяющий выбрать один вариант из выпадающего списка:</p>
<pre>
<code><select id="simple" name="simple"></code>
<code> <option>Банан</option></code>
<code> <option>Вишня</option></code>
<code> <option <mark>selected</mark>>Лимон</option></code>
<code></select></code>
</pre>
</section>
<section class="slide clear">
<img src="pictures/9/selectbox.png" alt="" class="cover h">
</section>
<section class="slide narfu">
<h2>Drop-down виджеты</h2>
<p>Виджет с возможностью выбрать сразу несколько вариантов:</p>
<pre>
<code><select <mark>multiple</mark> id="multi" name="multi"></code>
<code> <option>Банан</option></code>
<code> <option>Вишня</option></code>
<code> <option>Лимон</option></code>
<code></select></code>
</pre>
</section>
<section class="slide narfu">
<h2>Объединение input/text и опций</h2>
<div class="columns two">
<p>Можно объединить текстовое поле с возможностью выбора опций. С подобным вы наверняка встречались в
поисковиках.</p>
<img src="pictures/9/text+select.png" alt="" width="400">
</div>
</section>
<section class="slide narfu">
<pre>
<code><label for="myFruit">Какой твой любимый фрукт?</label></code>
<code><input type="text" id="myFruit" list="mySuggestion"></code>
<code class="mark"><datalist id="mySuggestion"></code>
<code> <option>Яблоко</option></code>
<code> <option>Банан</option></code>
<code> <option>Лимон</option></code>
<code> <option>Персик</option></code>
<code> <option>Груша</option></code>
<code class="mark"></datalist></code>
</pre>
</section>
<section class="slide white">
<img src="pictures/9/checkbox.png" alt="" class="cover h">
</section>
<section class="slide narfu">
<p>Чекбокс:</p>
<pre>
<code><input <mark>type="checkbox"</mark> checked id="carrots" </code>
<code> name="carrots" value="carrots"></code>
</pre>
<p>Радиокнопка:</p>
<pre>
<code><input <mark>type="radio"</mark> checked id="carrots" </code>
<code> name="carrots" value="carrots"></code>
</pre>
</section>
<section class="slide narfu">
<h2>Объединение радиокнопок</h2>
<pre style="font-size: smaller">
<code><fieldset></code>
<code> <legend>Что будем заказывать?</legend></code>
<code> <label for="soup">Суп</label></code>
<code> <input type="radio" id="soup" <mark>name="meal"</mark> value="soup"></code>
<code> <label for="curry">Крылышки из KFC</label></code>
<code> <input type="radio" id="curry" <mark>name="meal"</mark> value="curry"></code>
<code> <label for="pizza">Пицца</label></code>
<code> <input type="radio" id="pizza" <mark>name="meal"</mark> value="pizza"></code>
<code></fieldset></code>
</pre>
</section>
<section class="slide narfu">
<h2>Продвинутые виджеты</h2>
<ul>
<li>текстовое поле с возможностью вводить только цифры;</li>
<li>виджеты, где можно выбрать значения в определенном диапазоне;</li>
<li>виджет для выбора даты;</li>
<li>виджет для выбора цвета;</li>
<li>виджет для загрузки файла;</li>
</ul>
</section>
<section class="slide narfu">
<img src="pictures/9/dont-do-that.svg" alt="" class="cover w">
</section>
<section class="slide narfu">
<h2><input/number></h2>
<p>Синтаксис поля для ввода цифр:</p>
<pre>
<code><input type="<mark>number</mark>" name="age" id="age"</code>
<code> min="1" max="10" step="2"></code>
</pre>
<div class="columns two">
<ul>
<li><code>min</code> - минимальное значение;</li>
<li><code>max</code> - максимальное значение;</li>
<li><code>step</code> - шаг изменения значения.</li>
</ul>
<img src="pictures/9/number.png" alt="" style='margin-left: 25%;'>
</div>
</section>
<section class="slide narfu">
<h2>Ползунки</h2>
<pre>
<code><input type="<mark>range</mark>" name="beans" id="beans"</code>
<code> min="0" max="500" step="10"></code>
</pre>
<p>Подобный виджет позволяет выбирать между вариантами при помощи мыши или стрелок на клавиатуре.</p>
</section>
<section class="slide white">
<img src="pictures/9/slider.png" alt="" class="place center" style="margin-top: -20px;">
</section>
<section class="slide narfu">
<h2>Дата и время</h2>
<pre>
<code><input type="datetime-local"> <span class="comment"><!-- Выбрать дату --></span></code>
<code><input type="month"> <span class="comment"><!-- Выбрать месяц --></span></code>
<code><input type="time"> <span class="comment"><!-- Выбрать время --></span></code>
<code><input type="week"> <span class="comment"><!-- Выбрать неделю --></span></code>
</pre>
</section>
<section class="slide white">
<img src="pictures/9/date.png" alt="" class="cover h">
</section>
<section class="slide narfu clear">
<h2>Выбор цвета</h2>
<pre>
<code><input type="<mark>color</mark>" name="color" id="color"></code>
<code></code>
</pre>
<img src="pictures/9/standart-colopicker.png" alt="" class="place center" style="margin-top: 100px; width: 400px">
</section>
<section class="slide clear">
<img src="pictures/9/adobe-color.png" alt="" class="cover h">
</section>
<section class="slide narfu">
<h2>Загрузка файла</h2>
<pre>
<code><input type="<mark>file</mark>" name="file" id="file"</code>
<code> accept="image/*" multiple></code>
</pre>
<img src="pictures/9/file-picker.png" alt="" style="width: 100%; margin-top: 40px;">
</section>
<!-- Slide -->
<section class="slide clear">
<img src="pictures/9/ui-ux.jpeg" alt="" class="cover w h">
</section>
<!-- Footer -->
<section class="slide" id="see-more">
<h2 class="shout">
<a href="index.html">Все презентации<br>на GitHub Pages</a>
</h2>
</section>
<footer class="badge">
<a href="https://github.com/LoveSolaristics/shower-presentation.git">
<svg width="81" height="79" viewBox="0 0 81 79" aria-hidden="true">
<path d="M40.5 0a40.5 40.5 0 0 0-12.8 78.93c2 .37 2.76-.88 2.76-2s0-3.51-.05-6.89c-11.27 2.45-13.64-5.43-13.64-5.43-1.84-4.68-4.5-5.92-4.5-5.92-3.68-2.51.28-2.46.28-2.46 4.06.29 6.2 4.17 6.2 4.17 3.61 6.19 9.48 4.4 11.79 3.37a8.65 8.65 0 0 1 2.57-5.41c-9-1-18.45-4.5-18.45-20a15.65 15.65 0 0 1 4.17-10.87 14.57 14.57 0 0 1 .4-10.72s3.4-1.09 11.14 4.15a38.39 38.39 0 0 1 20.28 0c7.73-5.24 11.13-4.15 11.13-4.15a14.55 14.55 0 0 1 .4 10.72 15.63 15.63 0 0 1 4.16 10.87c0 15.56-9.47 19-18.49 20 1.45 1.25 2.75 3.72 2.75 7.5v11.11c0 1.08.73 2.34 2.78 1.95A40.51 40.51 0 0 0 40.5 0z"></path>
</svg>
Репозиторий<br>на GitHub
</a>
</footer>
<div class="progress"></div>
<script src="node_modules/@shower/core/dist/shower.js"></script>
</body>
</html>