Skip to content

component form

garevna edited this page May 20, 2019 · 2 revisions

cap-30 CSS-компонент "Форма"

Обратите внимание, что модификаторы form-component--email, form-component--password и form-component--name позволяют управлять содержимым формы

Для того, чтобы в форме отображались определенные поля, необходимо включить соответствующие модификаторы:

  • form-component--name чтобы в форме отображалось поле name
  • form-component--email чтобы в форме отображалось поле email
  • form-component--password чтобы в форме отображалось поле password

Добавляя или удаляя модификаторы, можно настраивать форму:

html
<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>
CSS
.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;
    }
}

© Irina H.Fylyppova 2019



Занятие 1


Занятие 2


Занятие 3


Занятие 4


Занятие 5


Занятие 6


Занятие 7


Занятие 8


Дополнительно

Clone this wiki locally