-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSearch bar advanced.html
135 lines (122 loc) · 4.38 KB
/
Search bar advanced.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Search Button and Bar</title>
<style>
:root {
--btn-d: 5em;
--txt-w: calc(4 * var(--btn-d));
--txt-h: calc(0.65 * var(--btn-d));
--txt-c: #ffeacc;
--mag-d: calc(0.5 * var(--txt-h));
--mag-f: 0.125;
--mag-w: calc(var(--mag-f) * var(--mag-d));
--mag-c: #000;
--t: 0.65s;
}
*, :before, :after {
box-sizing: border-box;
margin: 0;
padding: 0;
font: inherit;
}
html { overflow-x: hidden; }
body {
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
min-width: 400px;
min-height: 100vh;
background: #252525;
}
#search-btn {
position: absolute;
left: -100vw;
}
#search-btn ~ * {
--i: var(--pos, 1);
--j: calc(1 - var(--i));
}
#search-btn:checked ~ * { --pos: 0; }
[for='search-btn'] {
order: 1;
overflow: hidden;
position: relative;
z-index: 2;
margin-left: calc(-0.25 * var(--btn-d));
width: var(--btn-d);
height: var(--btn-d);
border-radius: 50%;
transform: translate(var(--pos, calc(-0.5 * var(--txt-w)))) rotate(45deg);
background: hsl(calc(336 - var(--i) * 269), calc(77% + var(--i) * 2%), calc(49% + var(--i) * 13%));
text-indent: -100vw;
transition: var(--t) ease-out;
cursor: pointer;
}
[for='search-btn']:before, [for='search-btn']:after {
position: absolute;
top: 50%;
left: 50%;
margin: calc(-0.5 * var(--mag-d));
width: var(--mag-d);
height: var(--mag-d);
transition: inherit;
content: '';
}
[for='search-btn']:before {
margin-top: calc(-0.4 * var(--mag-w));
height: var(--mag-w);
transform-origin: 100% 0;
transform: translate(var(--pos, calc(0.25 * var(--mag-d)))) scaleX(calc(1 - var(--i) * 0.5));
background: currentcolor;
}
[for='search-btn']:after {
border: solid var(--mag-w) currentcolor;
border-radius: calc(var(--i) * 50%);
transform: translate(var(--pos, calc(-0.25 * var(--mag-d)))) scaleX(calc(var(--j) * var(--mag-f) + var(--i)));
box-shadow: inset 0 0 0 calc(var(--j) * calc(0.5 * var(--mag-d))) currentcolor;
transition-property: border-radius, transform, box-shadow;
transition-timing-function:
cubic-bezier(calc(var(--j) * 0.42), 0, calc(1 - var(--i) * 0.42), 1),
cubic-bezier(calc(var(--i) * 0.42), 0, calc(1 - var(--j) * 0.42), 1);
}
#search-bar {
margin-right: calc(-0.25 * var(--btn-d));
border: none;
padding: 0 1em;
width: var(--txt-w);
height: var(--txt-h);
border-radius: var(--txt-h);
transform: translate(var(--pos, calc(0.5 * var(--txt-w))));
background: #3f324d;
--cp: inset(-2em var(--pos, 100%) -2em -2em);
-webkit-clip-path: var(--cp);
clip-path: var(--cp);
color: #fff;
font: 1em century gothic, verdana, arial, sans-serif;
transition: var(--t);
}
#search-bar::placeholder {
opacity: 0.5;
color: inherit;
font-size: 0.875em;
letter-spacing: 1px;
text-shadow: 0 0 1px, 0 0 2px;
}
#search-bar:focus {
outline: none;
box-shadow: 0 0 1.5em var(--txt-c), 0 1.25em 1.5em rgba(0, 0, 0, 0.2);
background: var(--txt-c);
color: #000;
}
</style>
</head>
<body>
<input id="search-btn" type="checkbox"/>
<label for="search-btn">Show search bar</label>
<input id="search-bar" type="text" placeholder="Search..."/>
</body>
</html>