-
Notifications
You must be signed in to change notification settings - Fork 2
component form
garevna edited this page May 20, 2019
·
2 revisions
![]() |
|---|
Обратите внимание, что модификаторы form-component--email, form-component--password и form-component--name позволяют управлять содержимым формы
Для того, чтобы в форме отображались определенные поля, необходимо включить соответствующие модификаторы:
-
form-component--nameчтобы в форме отображалось полеname -
form-component--emailчтобы в форме отображалось полеemail -
form-component--passwordчтобы в форме отображалось полеpassword
Добавляя или удаляя модификаторы, можно настраивать форму:
![]() |
|---|
<form action="#"
class="form-component
form-component--email
form-component--password">
<div class="form-col form-col-name" before="Enter your name: ">
<input type="text" placeholder="Name">
</div>
<div class="form-col form-col-email" before="Enter your email here: ">
<input type="email" placeholder="Email">
</div>
<div class="form-col form-col-password" before="Do you remember your password? ">
<input type="password" placeholder="Password">
</div>
<button type="submit">Submit</button>
</form>.form-component {
margin: 10vh 10vw;
height: max-content;
border: inset 1px;
box-sizing: border-box;
text-align: center;
font-family: Arial;
padding: 10%;
background: #eef;
}
.form-component .form-col {
width: 80%;
margin: 2rem 10%;
display: none;
}
.form-component--name .form-col-name,
.form-component--email .form-col-email,
.form-component--password .form-col-password {
display: block;
}
.form-component .form-col input {
display: inline-block;
vertical-align: middle;
border: 1px inset;
padding: 1rem 2rem;
margin-top: 1rem;
}
.form-component .form-col:before {
content: attr(before);
color: #333;
}
.form-component button {
padding: 1rem 2rem;
font-size: 1.2rem;
}
@media screen and (max-width:480px) {
.form-component {
margin: 10vh 0;
padding: 0;
}
.form-component .form-col {
padding: 0;
}
.form-component .form-col input {
max-width: 50vh;
padding: 0.8rem 0.5rem;
}
.form-component button {
padding: 0.5rem 0.5rem;
font-size: 1.0rem;
margin-bottom: 2rem;
}
}
CSS-компонент "Форма"

Всемирная паутина
Пример