-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
105 lines (98 loc) · 2.42 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<title>Document</title>
<style>
body {
margin: 0;
padding: 0;
}
a {
color: blue;
text-decoration: none;
}
.search-header-form {
position: fixed;
width: 100%;
top: 0;
background: #fff;
z-index: 999;
height: 80px;
transform: translateY(-100%);
transform-style: preserve-3d;
transition: transform .2s,box-shadow .2s;
pointer-events: auto;
}
.search-header-form .fa-search {
position: absolute;
left: 15px;
top: 25px;
border: none;
background: 0;
font-size: 25px;
cursor: pointer;
}
.search-header-form input[type="text"] {
height: 80px;
width: 100%;
line-height: 80px;
outline: none;
padding: 0 30px 0 60px;
border: none;
font-size: 18px;
}
.search-header-form.is-open {
box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
transform: translate(0);
}
#overlay {
background: rgba(0,0,0, 0.2);
position: fixed;
transition: opacity .4s cubic-bezier(.694,0,.335,1), visibility 0ms cubic-bezier(.694,0,.335,1) .4s;
top: 0;
right: 0;
left: 0;
bottom: 0;
height: 100%;
width: 100%;
z-index: 98;
cursor: pointer;
visibility: hidden;
opacity: 0;
}
#overlay.is-open {
opacity: 1;
transition: opacity .4s cubic-bezier(.694,0,.335,1), visibility 0ms cubic-bezier(.694,0,.335,1);
visibility: visible;
pointer-events: auto;
}
</style>
</head>
<body>
<div id="overlay"></div>
<div class="search-header-form">
<form method="get" action="/">
<input type="text" placeholder="Start search..." name="s" id="search-field" value="" autocomplete="off">
<button type="submit" class="fa fa-search"></button>
</form>
</div>
<a href="#" class="fa fa-search search-icon"></a>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script>
$('.search-icon').click(function(e){
e.preventDefault();
$('.search-header-form, #overlay').addClass('is-open');
});
$(document).click(function (e) {
var div = $(".search-header-form, .fa-search");
if (!div.is(e.target) && div.has(e.target).length === 0) {
console.log($(e.target));
$('.search-header-form, #overlay').removeClass('is-open');
}
});
</script>
</body>
</html>