-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinput-material.scss
99 lines (86 loc) · 2.4 KB
/
input-material.scss
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
.form-group.input-material {
// variables (normally global variables in Bootstrap scss)
$gray-400: #ced4da;
$primary: #007bff;
$danger: #dc3545;
$black: #000;
// local variables
$inactive-color: $gray-400;
position: relative;
margin-top: 50px;
margin-bottom: 25px;
label {
color: darken($inactive-color, 10%);
font-size: 16px;
font-weight: normal;
position: absolute;
pointer-events: none;
left: 5px;
bottom: 1px;
transition: 0.1s ease all;
-moz-transition: 0.1s ease all;
-webkit-transition: 0.1s ease all;
}
/* textarea label */
textarea.form-control {
&~ label {
bottom: 90%; // fallback for browsers that do not support calc()
bottom: calc(100% - 38px);
}
}
.form-control, .form-select {
border: none;
border-bottom: 2px solid $inactive-color;
border-radius: 0px;
background-color: transparent;
padding-left: 5px;
box-shadow: none;
/* required fields */
&:required ~ label::after {
content: '*';
color: $danger;
padding-left: 2px;
font-size: 0.8em;
}
/* active state */
&:focus,
&[value]:not([value=""]) {
border-bottom-color: $primary;
color: $black;
}
&:focus ~ label,
&[value]:not([value=""]) ~ label {
top: unset;
bottom: 100%; // fallback for browsers without calc() support
bottom: calc(100% - 16px);
font-size: 14px;
color: $primary;
font-weight: 500;
}
/* invalid state */
&:focus.invalid,
&.invalid,
&:focus.parsley-error,
&[value]:not([value=""]).parsley-error {
border-bottom-color: $danger;
}
&:focus.invalid ~ label,
&.invalid ~ label,
&:focus.parsley-error ~ label,
&[value]:not([value=""]).parsley-error ~ label {
color: $danger;
}
}
.form-select {
background-position: right 0 center;
padding-left: 0;
}
.parsley-errors-list {
color: $danger;
list-style: none;
font-size: 0.7em;
padding-left: 5px;
position: absolute;
top: 107%;
}
}