-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndex.html
More file actions
77 lines (73 loc) · 3.28 KB
/
Index.html
File metadata and controls
77 lines (73 loc) · 3.28 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Responsive Lite Dropdown Menu</title>
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/header.css" />
<link rel="stylesheet" href="css/responsive_mobile.css" />
</head>
<body>
<div class="body-container">
<header>
<nav class="navbar container-fluid">
<a href="/" class="logo"><img class="logo-img" src="images/logo-desktop.png" /></a>
<ul class="nav-list">
<li class="nav-item"><a href="/">Home Page</a></li>
<li class="nav-item"><a href="javascript:;">Category 1</a></li>
<li class="nav-item dropdown">
<a href="javascript:;"><span>Category 2<img src="images/white-drop-down-arrow.png" /></span></a>
<ul class="dropdown-menu">
<li><a href="javascript:;">Category 2a</a></li>
<li><a href="javascript:;">Category 2b</a></li>
</ul>
</li>
<li class="nav-item"><a href="javascript:;">Category 3</a></li>
<li class="nav-item"><a href="javascript:;">Category 4</a></li>
<li class="nav-item"><a href="javascript:;">Category 5</a></li>
<li class="nav-item"><a href="javascript:;">Category 6</a></li>
<li class="nav-item"><a href="javascript:;">Category 7</a></li>
</ul>
<div class="menu-icon">
<div class="menu-icon-container" onclick="clickMobileMenu(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
</div>
</nav>
</header>
</div>
<script>
function clickMobileMenu(x) {
var menuList = document.querySelector(".nav-list");
if (x.classList.contains('change')) {
menuList.style.display = "none";
}
else {
menuList.style.display = "flex";
}
x.classList.toggle("change");
}
// Attach the event listener to the window's resize event
window.addEventListener('resize', handleResize);
// Call handleResize initially to check the screen width on page load
handleResize();
function handleResize() {
// Get the current screen width
var screenWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
// Specify the target width
var smallDevicesWidth = 480; // Change this to your specified number
var menuList = document.querySelector(".nav-list");
var menuIcon = document.querySelector(".menu-icon-container");
// Check if the screen width matches the specified number
if (screenWidth > smallDevicesWidth) {
menuList.style.display = "flex";
}
else if (!menuIcon.classList.contains('change')) {
menuList.style.display = "none";
}
}
</script>
</body>
</html>