Quellcode durchsuchen

mobile search fix

@Mostafijur vor 1 Jahr
Ursprung
Commit
55181cbb31
2 geänderte Dateien mit 25 neuen und 21 gelöschten Zeilen
  1. 4 3
      css/style.css
  2. 21 18
      js/app.js

+ 4 - 3
css/style.css

@@ -479,12 +479,13 @@ a {
 @media screen and (max-width: 1199px) {
     #header .search  {
         position: absolute;
-        top: 120px;
+        top: 115px;
         width: 100%;
         display: none;
         z-index: 30;
-        background: var(--white);
-        padding: .25rem;
+        background: var(--white-light);
+        padding: 1rem;
+        box-shadow: var(--shadow-black);
     }
     #header .search.active  {
         display: block;

+ 21 - 18
js/app.js

@@ -52,27 +52,32 @@ const searchButton = document.querySelector(".search-btn-mobile")
   // header sub-menu
 
   const megaSubMenu = document.querySelectorAll('.megamenu-submenu .items');
-  const subMenuItemsAll = document.querySelectorAll('.megamenu-submenu .submenu-items')
-
 
-  megaSubMenu.forEach(menu => {
-    const subMenuBtn = menu.querySelector('.submenu-buton');
-    const subMenuItems = menu.querySelector('.submenu-items')
+  const subMenuItemsAll = document.querySelectorAll('.megamenu-submenu .submenu-items')
 
-    if (subMenuItems && subMenuBtn) {
+  if(megaSubMenu) {
 
-      subMenuBtn.addEventListener('click', () => {
-        subMenuItems.classList.toggle('active')
+    megaSubMenu.forEach(menu => {
+      const subMenuBtn = menu.querySelector('.submenu-buton');
+      const subMenuItems = menu.querySelector('.submenu-items')
   
-        subMenuItemsAll.forEach(item => {
-          if (item !== subMenuItems) {
-            item.classList.remove("active")
-          }
+      if (subMenuItems && subMenuBtn) {
+  
+        subMenuBtn.addEventListener('click', () => {
+          subMenuItems.classList.toggle('active')
+    
+          subMenuItemsAll.forEach(item => {
+            if (item !== subMenuItems) {
+              item.classList.remove("active")
+            }
+          })
         })
-      })
-      
-    }
-  })
+        
+      }
+    })
+
+  }
+
 
 
   // burger menu function
@@ -139,8 +144,6 @@ const searchButton = document.querySelector(".search-btn-mobile")
   const checkoutContainer = document.querySelector('.checkout-container')
 
 
-
-
           // checkout open function for desktop
       if(checkoutProductBtnDesktop && checkoutContainer) {
         checkoutProductBtnDesktop.addEventListener('click', () => {