Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Современные информационные технологии. 4 курс. Лабораторное занятие №5. Интерактивные формы

Для создания интерактивной формы вам потребуется:
Файл стилей CSS, динамический сценарий JavaScript и HTML, размещаемый в отдельном сообщении в блоге, а также немного фантазии для составления вопросов и вариантов ответов. Итоговый вариант у вас должен быть с вашими собственными цветами.

I Параметры стилей
1) Для начала в CSS разворачиваем параметры сглаживания и отображения текста:

html {
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased !important;
}

2) Далее задаем основные фоновые цвета и цвет текста:

body {
  background-color: rgb(17, 17, 17);
  font-family: 'Roboto Slab';
  color:#fff;
}

3) Открываем классы обертки и формы интерактивного блока:

.wrapper {
  height: 350px;
  width: 700px;
  margin: 40px auto;
}

.quiz-box {
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 1);
    background-color: #000;
    border-radius: 0px 10%;
    box-shadow: 0px 0px 13px 2px rgb(0, 0, 0);
}

4) Теперь навигационные кнопки и сам блок:

.navigation-buttons {
  text-align: center;
  padding: 10px 0px;
  float: right;
}

.name-box {
  text-align: center;
  padding: 10%;
  height: 100%;
}

.name-box span {
  font-weight: 500;
  font-size: 3em;
}

5) Теперь параметры ввода данных и взаимодействия курсора с блоком:

#name-input-box {
  height: 45px;
  padding: 0;
  margin-top: 20px;
  font: 400 3rem 'Roboto Slab';
  letter-spacing: 0.025em;
  border: none;
  background: transparent;
  text-align: center;
  outline: none;
  border-bottom: solid thin rgba(238, 238, 238, 0.12);
}

button {
  border: none;
  width: 100px;
  height: 30px;
  text-align: center;
  border-radius: 0px 10px;
  background: transparent;
  outline: none;
}

button:hover {
  cursor: pointer;
  border: 2px solid #fff;
  border-radius: 0px 10px;
}

button:disabled{
  display:none;
}

#name-submit-button {
  margin-top: 30px;
}

6) В классе опроса и его опций указываем размеры и шрифты:

.quiz {
  height: 100%;
  padding: 10px;
}

#question h2 {
  font-weight: 600;
  padding: 20px;
}

.options {
  height: 70%;
  height: 100%;
  padding-left: 20px;
}

.options label {
  width: 49%;
}

7) Дальше Super CSS с директивой:

@-webkit-keyframes click-wave {
  0% {
    height: 40px;
    width: 40px;
    opacity: 0.35;
    position: relative;
    outline: none;
  }
  100% {
    height: 200px;
    width: 200px;
    margin-left: -80px;
    margin-top: -80px;
    opacity: 0;
    outline: none;
  }
}

@-moz-keyframes click-wave {
  0% {
    height: 40px;
    width: 40px;
    opacity: 0.35;
    position: relative;
    outline: none;
  }
  100% {
    height: 200px;
    width: 200px;
    margin-left: -80px;
    margin-top: -80px;
    opacity: 0;
    outline: none;
  }
}

@keyframes click-wave {
  0% {
    height: 40px;
    width: 40px;
    opacity: 0.35;
    position: relative;
    outline: none;
  }
  100% {
    height: 200px;
    width: 200px;
    margin-left: -80px;
    margin-top: -80px;
    opacity: 0;
    outline: none;
  }
}

8) Инпут-опциив том числе easing:

.option-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  -ms-appearance: none;
  -o-appearance: none;
  appearance: none;
  position: relative;
  right: 0;
  bottom: 0;
  left: 0;
  height: 40px;
  width: 40px;
  top: 13px;
  -webkit-transition: all 0.15s ease-out 0s;
  -moz-transition: all 0.15s ease-out 0s;
  transition: all 0.15s ease-out 0s;
  border: none;
  color: #fff;
  cursor: pointer;
  display: inline-block;
  margin-right: 0.5rem;
  outline: none;
  position: relative;
  z-index: 1000;
}

.option-input:hover {
  background: #9faab7;
  outline: none;
}

.option-input:checked {
  background: black;
}

.option-input:checked::before {
  height: 40px;
  width: 40px;
  position: absolute;
  content: '\2713';
  display: inline-block;
  font-size: 26.66667px;
  text-align: center;
  line-height: 40px;
}

.option-input:checked::after {
  -webkit-animation: click-wave 0.65s;
  -moz-animation: click-wave 0.65s;
  animation: click-wave 0.65s;
  background: white;
  content: '';
  display: block;
  position: relative;
  z-index: 100;
}

.option-input.radio {
  border-radius: 50%;
  outline: none !important;
  margin-right: 10px;
  border: 2px solid #fff;
}

.option-input.radio::after {
  border-radius: 50%;
  outline: none;
}

9) Горизонтальное отображение блока:

label {
  display: inline-block;
  width: 50%;
  float: left;
  padding-left: 20px;
  font-weight: 500;
  font-size: 1.3em;
}

10) Стили результата опроса:

.score-detail,.chart {
    display: inline-block;
    width: 49%;
    text-align: center;
    vertical-align: top;
    margin-top:10px;
}


.easyPieChart {
  position: relative;
  text-align: center;
}
.easyPieChart canvas {
  position: absolute;
  top: 0;
  left: 0;
}

.percentage,
.label {
  margin-bottom: 0.5em;
  text-align: center;
  font-weight: 100;
}

.percentage {
  font-size: 17px;
}

sup {
  top: -0.2em;
  margin-left: 1px;
}

.ctrl {
  position: absolute;
  right: 10px;
  top: 5px;
  color: #c4cdcc;
  word-spacing: 5px;
}

11) Таблица формы результатов:

#result{
  padding:10px;
  height:100%;
}
#result .score-label h1{
  font-weight:600;
}
#result .score-label h1 i{
  margin-left:10px;
}
#result .score-label h1,#result .message{
  text-align:center;
}

#result .score-detail h3{
  margin-top: 19px;
  padding-left: 15px;
}

#result-stats{
  padding:20px;
}

table, td, th {
  padding:10px;
}
table {
    border-collapse: collapse;
    width: 100%;
}
table td .grey{
  color:rgba(255, 255, 255, 0.47);
}
th {
    text-align: left;
  font-size:1.2em;
}
#result-stats .fa{
  margin-right:5px;
}

#result-stats .fa-check-circle{
  color:#06ff00;
}
#result-stats .fa-times-circle{
  color:#ff3d00;
}

12) Сохраняете стили как CSS и затем через google sites встраиваете в HTML перед закрывающим тегом <head>.

II Динамика интерактивной формы:

13) Поскольку подобные формы предусматривают развернутый JavaScript-сценарий (в данном случае 292 строки скрипта), то здесь лежит уже готовый шаблон, который вам нужно доработать под вашу интерактивную форму: https://sites.google.com/site/konoplevmedia/editablescript.js


Пояснения к шаблону:

строка 2: переменные цветов в окне опроса.

строки 5-17: переменная вопроса с указанием формулировки и вариантами ответов и помеченным правильным ответом. Обратите внимание, что блоки вопросов отделяются друг от друга запятой.

В примере 2 вопроса, у вас должно быть не менее шести.

строки 118-134: сообщения, выводимые в зависимости от числа правильных ответов и цвет, привязанный к результату. Замените на свой.

строка 136: текст окна результата.

14) Готовый JavaScript файл вам нужно загрузить на google sites и затем встроить в HTML перед закрывающим тегом <body>

III Подключение HTML

15) Сначала указываем тип страницы, язык и в теге хэдера формальный заголовок:

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Quizpage</title>


16) Встраиваем стандарты Font Awesome, шрифты Google и библиотеку стилей:
  
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Roboto+Slab:100,300,400,700'>
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'>

17) Закрываем тег <head> и открываем тег <body>

18) Объявляем класс контейнера и обертки:

  <div class="quiz-box-container">
        <div class="wrapper">
            <div class="quiz-box">
                <div class="name-box">

19) Теперь дублируем форму запроса:

<span>Ваше имя</span>
<br>
<form id="name-form">
<input type="text" id="name-input-box" />
<br>
<button type="submit" id="name-submit-button">Начать</button>
</form>
</div>

20) Создаем класс блока опроса:

<div id="question-box">
</div>
 <div id="result">
<div class="score-label">
  <h1><i class="smiley"></i></h1>
 </div>
 <div>

21) Класс счетчика:

<div class="score-detail">
<h3></h3>
<div class="chart">
<div class="percentage" data-percent="100">
 <span></span><sup>%</sup>
</div>
</div>
<h3 class="message"></h3>
</div>
 </div>

22) Класс результатов:

<div id="result-stats">
<table>
<tr>
 <th>Вопрос</th>
<th>Ваш ответ</th>
 <th>Правильный ответ</th>
</tr>
</table>
</div>
</div>

23) Класс кнопок навигации:

<div class="navigation-buttons">
<button id="prevButton">Назад</button>
<button id="nextButton">Дальше</button>
<button id="submitButton">Завершить</button>
<button id="resultButton">Итог</button>
</div>
</div>
</div>

24) Встраиваем стандарт библиотек и пайчарта:

<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='https://rendro.github.io/easy-pie-chart/javascripts/jquery.easy-pie-chart.js'></script>

25) Закрываем теги  <body> и <html>.

Quiz - App
Ваше имя

%

Вопрос Ваш ответ Правильный ответ

Если все верно, то ваш опрос будет выглядеть как на этой странице. Ссылки на выполненное задание принимаются в комментарии к данному посту до 20:00 25 февраля.

Комментарии

Популярные сообщения