-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
124 lines (117 loc) · 3.49 KB
/
test.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
<!-- https://velog.io/@kauthenticity/HTML-CSS-%EB%93%9C%EB%A1%AD%EB%8B%A4%EC%9A%B4-%EB%A9%94%EB%89%B4-%EB%A7%8C%EB%93%A4%EA%B8%B0 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@import url('https://fonts.googleapis.com/icon?family=Material+Icons');
.dropdown{
position : relative;
display : inline-block;
}
.dropbtn_icon{
font-family : 'Material Icons';
}
.dropbtn{
display : block;
border: none;
background-color: #fcfcfc;
font-weight: 400;
color : rgb(124, 124, 124);
padding : 12px;
width :150px;
text-align: left;
cursor : pointer;
font-size : 15px;
z-index :1;
position : relative;
}
.dropdown-content{
display : none;
font-weight: 400;
background-color: #fcfcfc;
min-width : 150px;
border-radius: 8px;
height : 160px;
overflow : scroll;
box-shadow: 0px 0px 10px 3px rgba(190, 190, 190, 0.6);
}
.dropdown-content::-webkit-scrollbar{
width : 5px;
height : 10px;
}
.dropdown-content::-webkit-scrollbar-thumb{
border-radius : 2px;
background-color :rgb(194, 194, 194)
}
.dropdown-content div{
display : block;
text-decoration : none;
color : rgb(37, 37, 37);
font-size: 12px;
padding : 12px 20px;
}
.dropdown-content div:hover{
background-color: rgb(226, 226, 226);
}
.dropdown-content.show{
display : block;
}
</style>
</head>
<body>
<div class="dropdown">
<button class="dropbtn">
<span class="dropbtn_content" onmouseover="dropdown()">Select a menu </span>
<span class="drop icon" style="font-family: Material Icons; font-size : 16px; color : #3b3b3b; float:right;"
>arrow_drop_down</span>
</button>
</div>
<div class="dropdown-content">
<div class="fastfood" onclick="showMenu(this.innerText)">Burgerking</div>
<div class="fastfood" onclick="showMenu(this.innerText)">Mcdonals</div>
<div class="fastfood" onclick="showMenu(this.innerText)">Lotteria</div>
<div class="fastfood" onclick="showMenu(this.innerText)">Mom's touch</div>
</div>
</div>
<script>
window.onload=()=>{
document.querySelector('.dropbtn_content').onmouseover = ()=>{
dropdown();
}
document.getElementsByClassName('fastfood').onclick = ()=>{
showMenu(value);
};
dropdown = () => {
var v = document.querySelector('.dropdown-content');
var dropbtn = document.querySelector('.dropbtn')
v.classList.toggle('show');
}
showMenu=(value)=>{
var dropbtn_content = document.querySelector('.dropbtn_content');
var dropbtn_click = document.querySelector('.dropbtn_click');
var dropbtn = document.querySelector('.dropbtn');
dropbtn_content.innerText = value;
dropbtn_content.style.color = '#252525';
}
}
window.onclick= (e)=>{
if(!e.target.matches('.dropbtn_click')){
var dropdowns = document.getElementsByClassName("dropdown-content");
var dropbtn_content = document.querySelector('.dropbtn_content');
var dropbtn_click = document.querySelector('.dropbtn_click');
var dropbtn = document.querySelector('.dropbtn');
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}</script>
</body>
</html>