AFTER hours of trying the dropdown menu is now up to stanard from Patrick_Pluto

This commit is contained in:
Sage The DM 2024-06-24 19:24:56 +02:00
parent 2055990ba9
commit f2895a3b0e
4 changed files with 33 additions and 15 deletions

View file

@ -1,6 +1,24 @@
// @license magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt CC0-1.0
// burger.js
function toggleMenu() {
const menu = document.querySelector(".menu");
menu.classList.toggle("active");
const menu = document.querySelector(".menu");
menu.classList.toggle("active");
// Add event listener to close menu when clicking anywhere on the document
if (menu.classList.contains("active")) {
document.addEventListener("click", closeMenu);
} else {
document.removeEventListener("click", closeMenu);
}
}
function closeMenu(event) {
const menu = document.querySelector(".menu");
if (!menu.contains(event.target) && !event.target.classList.contains("burger-menu")) {
menu.classList.remove("active");
document.removeEventListener("click", closeMenu);
}
}
// @license-end

View file

@ -12,7 +12,7 @@ class Header extends HTMLElement {
<header>
<div class="header-content">
<div class="project-name"><a href="../index.html">FOSS alternatives</a></div>
<button class="burger-menu" onclick="toggleMenu()"></button>
<button class="burger-menu" style="display: block;" onclick="toggleMenu()"></button>
<ul class="menu">
<li><a href="../games/index.html">Games</a></li>
<li><a href="../general_purpose/index.html">General Purpose</a></li>
@ -28,5 +28,5 @@ class Header extends HTMLElement {
}
customElements.define('header-component', Header);
customElements.define('header-component', Header);
// @license-end

View file

@ -4,7 +4,7 @@
margin: 0;
padding: 0;
font-family: "Roboto", Arial, sans-serif;
transition: all 0.3s ease; /* Smooth transitions */
transition: all 2s ease; /* Smooth transitions */
}
/* Body styles */

View file

@ -4,7 +4,7 @@
margin: 0;
padding: 0;
font-family: "Roboto", Arial, sans-serif;
transition: all 0.3s ease; /* Smooth transitions */
transition: all 2s ease; /* Smooth transitions */
}
/* Body styles */
@ -21,7 +21,7 @@ body {
/* Header styles */
header {
background-color: #2c3e50;
padding: 15px 0;
padding: 15px 0; /* Adjusted padding */
width: 100%;
position: fixed;
top: 0;
@ -36,12 +36,12 @@ header {
align-items: center;
max-width: 1200px;
margin: 0 auto;
padding: 0 20px;
padding: 0 20px; /* Original padding */
}
.project-name {
color: #ffffff;
font-size: 1.8em;
font-size: 1.5em; /* Updated font size */
font-weight: bold;
}
@ -49,7 +49,7 @@ header {
background: none;
border: none;
color: #ffffff;
font-size: 1.8em;
font-size: 1.5em; /* Updated font size */
cursor: pointer;
display: none;
}
@ -64,13 +64,13 @@ header {
}
header li {
margin: 15px;
margin: 10px; /* Smaller margin */
}
header a {
color: #ffffff;
text-decoration: none;
padding: 10px;
padding: 8px; /* Smaller padding */
border-radius: 5px;
transition: background-color 0.3s ease;
}
@ -198,11 +198,11 @@ nav {
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 0 20px 0 20px;
padding: 0 20px; /* Original padding */
}
.project-name {
font-size: 1.5em;
font-size: 1.5em; /* Updated font size */
}
header li {