2017-10-10 1 views
1

funktioniert auf Handy auf Vollbild, aber ich kann die Drop-Down-Optionen auf schweben nicht wählen, weil die Option verschwindetkann nicht das ansprechende Menü erhalten x arbeiten (

Mein Code:.

$('.handle').on('click', function(){ 
 
     $('nav ul').toggleClass('showing'); 
 
    });
body { 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t font-family: sans-serif; 
 
} 
 
.toggle, 
 
[id^=drop] { 
 
\t display: none; 
 
} 
 

 
/* Giving a background-color to the nav container. */ 
 
nav { 
 
\t margin:0; 
 
\t padding: 0; 
 
\t background-color: #254441; 
 
} 
 

 
#logo { 
 
\t display: block; 
 
\t padding: 0 30px; 
 
\t float: left; 
 
\t font-size:20px; 
 
\t line-height: 60px; 
 
} 
 

 
/* Since we'll have the "ul li" "float:left" 
 
* we need to add a clear after the container. */ 
 

 
nav:after { 
 
\t content:""; 
 
\t display:table; 
 
\t clear:both; 
 
} 
 

 
/* Removing padding, margin and "list-style" from the "ul", 
 
* and adding "position:reltive" */ 
 
nav ul { 
 
\t float: right; 
 
\t padding:0; 
 
\t margin:0; 
 
\t list-style: none; 
 
\t position: relative; 
 
\t } 
 
\t 
 
/* Positioning the navigation items inline */ 
 
nav ul li { 
 
\t margin: 0px; 
 
\t display:inline-block; 
 
\t float: left; 
 
\t background-color: #254441; 
 
\t } 
 

 
/* Styling the links */ 
 
nav a { 
 
\t display:block; 
 
\t padding:14px 20px; \t 
 
\t color:#FFF; 
 
\t font-size:17px; 
 
\t text-decoration:none; 
 
} 
 

 

 
nav ul li ul li:hover { background: #000000; } 
 

 
/* Background color change on Hover */ 
 
nav a:hover { 
 
\t background-color: #000000; 
 
} 
 

 
/* Hide Dropdowns by Default 
 
* and giving it a position of absolute */ 
 
nav ul ul { 
 
\t display: none; 
 
\t position: absolute; 
 
\t /* has to be the same number as the "line-height" of "nav a" */ 
 
\t top: 60px; 
 
} 
 
\t 
 
/* Display Dropdowns on Hover */ 
 
nav ul li:hover > ul { 
 
\t display:inherit; 
 
} 
 
\t 
 
/* Fisrt Tier Dropdown */ 
 
nav ul ul li { 
 
\t width:170px; 
 
\t float:none; 
 
\t display:list-item; 
 
\t position: relative; 
 
} 
 

 
/* Second, Third and more Tiers \t 
 
* We move the 2nd and 3rd etc tier dropdowns to the left 
 
* by the amount of the width of the first tier. 
 
*/ 
 
nav ul ul ul li { 
 
\t position: relative; 
 
\t top:-60px; 
 
\t /* has to be the same number as the "width" of "nav ul ul li" */ 
 
\t left:170px; 
 
} 
 

 
\t 
 
/* Change ' +' in order to change the Dropdown symbol */ 
 
li > a:after { content: ' +'; } 
 
li > a:only-child:after { content: ''; } 
 

 

 
/* Media Queries 
 
--------------------------------------------- */ 
 

 
@media all and (max-width : 768px) { 
 

 
\t #logo { 
 
\t \t display: block; 
 
\t \t padding: 0; 
 
\t \t width: 100%; 
 
\t \t text-align: center; 
 
\t \t float: none; 
 
\t } 
 

 
\t nav { 
 
\t \t margin: 0; 
 
\t } 
 

 
\t /* Hide the navigation menu by default */ 
 
\t /* Also hide the */ 
 
\t .toggle + a, 
 
\t .menu { 
 
\t \t display: none; 
 
\t } 
 

 
\t /* Stylinf the toggle lable */ 
 
\t .toggle { 
 
\t \t display: block; 
 
\t \t background-color: #254441; 
 
\t \t padding:14px 20px; \t 
 
\t \t color:#FFF; 
 
\t \t font-size:17px; 
 
\t \t text-decoration:none; 
 
\t \t border:none; 
 
\t } 
 

 
\t .toggle:hover { 
 
\t \t background-color: #000000; 
 
\t } 
 

 
\t /* Display Dropdown when clicked on Parent Lable */ 
 
\t [id^=drop]:checked + ul { 
 
\t \t display: block; 
 
\t } 
 

 
\t /* Change menu item's width to 100% */ 
 
\t nav ul li { 
 
\t \t display: block; 
 
\t \t width: 100%; 
 
\t \t } 
 

 
\t nav ul ul .toggle, 
 
\t nav ul ul a { 
 
\t \t padding: 0 40px; 
 
\t } 
 

 
\t nav ul ul ul a { 
 
\t \t padding: 0 80px; 
 
\t } 
 

 
\t nav a:hover, 
 
    \t nav ul ul ul a { 
 
\t \t background-color: #000000; 
 
\t } 
 
    
 
\t nav ul li ul li .toggle, 
 
\t nav ul ul a, 
 
    nav ul ul ul a{ 
 
\t \t padding:14px 20px; \t 
 
\t \t color:#FFF; 
 
\t \t font-size:17px; 
 
\t } 
 
    
 
    
 
\t nav ul li ul li .toggle, 
 
\t nav ul ul a { 
 
\t \t background-color: #212121; 
 
\t } 
 

 
\t /* Hide Dropdowns by Default */ 
 
\t nav ul ul { 
 
\t \t float: none; 
 
\t \t position:static; 
 
\t \t color: #ffffff; 
 
\t \t /* has to be the same number as the "line-height" of "nav a" */ 
 
\t } 
 
\t \t 
 
\t /* Hide menus on hover */ 
 
\t nav ul ul li:hover > ul, 
 
\t nav ul li:hover > ul { 
 
\t \t display: none; 
 
\t } 
 
\t \t 
 
\t /* Fisrt Tier Dropdown */ 
 
\t nav ul ul li { 
 
\t \t display: block; 
 
\t \t width: 100%; 
 
\t } 
 

 
\t nav ul ul ul li { 
 
\t \t position: static; 
 
\t \t /* has to be the same number as the "width" of "nav ul ul li" */ 
 

 
\t } 
 

 
} 
 

 
@media all and (max-width : 330px) { 
 

 
\t nav ul li { 
 
\t \t display:block; 
 
\t \t width: 94%; 
 
\t } 
 

 
}
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> 
 
<body> 
 
    <nav> 
 
     <div id="logo">Your Logo here</div> 
 

 
     <label for="drop" class="toggle">Menu</label> 
 
     <input type="checkbox" id="drop" /> 
 
      <ul class="menu"> 
 
       <li><a href="#">Home</a></li> 
 
       <li> 
 
        <!-- First Tier Drop Down --> 
 
        <label for="drop-1" class="toggle">WordPress +</label> 
 
        <a href="#">WordPress</a> 
 
        <input type="checkbox" id="drop-1"/> 
 
        <ul> 
 
         <li><a href="#">Themes and stuff</a></li> 
 
         <li><a href="#">Plugins</a></li> 
 
         <li><a href="#">Tutorials</a></li> 
 
        </ul> 
 

 
       </li> 
 
       <li> 
 

 
       <!-- First Tier Drop Down --> 
 
       <label for="drop-2" class="toggle">Web Design +</label> 
 
       <a href="#">Web Design</a> 
 
       <input type="checkbox" id="drop-2"/> 
 
       <ul> 
 
        <li><a href="#">Resources</a></li> 
 
        <li><a href="#">Links</a></li> 
 
        <li> 
 
         
 
        <!-- Second Tier Drop Down -->   
 
        <label for="drop-3" class="toggle">Tutorials +</label> 
 
        <a href="#">Tutorials</a>   
 
        <input type="checkbox" id="drop-3"/> 
 

 
        <ul> 
 
         <li><a href="#">HTML/CSS</a></li> 
 
         <li><a href="#">jQuery</a></li> 
 
         <li><a href="#">Other</a></li> 
 
        </ul> 
 
        </li> 
 
       </ul> 
 
       </li> 
 
       <li><a href="#">Graphic Design</a></li> 
 
       <li><a href="#">Inspiration</a></li> 
 
       <li><a href="#">Contact</a></li> 
 
       <li><a href="#">About</a></li> 
 
      </ul> 
 
     </nav>

hier ist eine Geige so können Sie sehen, was ich rede Jungs:

http://jsfiddle.net/p1mrtuex/9/

bitte helfen!

Antwort

0

Das Dropdown-Menü ist weiter von der Navigation entfernt. Ändern Sie die nav ul ul zu 40px. Es bewegt das Dropdown-Menü näher zum Navigationsbereich und Sie können nun das Dropdown-Menü auswählen.

$('.handle').on('click', function(){ 
 
      $('nav ul').toggleClass('showing'); 
 
     });
body { 
 
    \t margin: 0; 
 
    \t padding: 0; 
 
    \t font-family: sans-serif; 
 
    } 
 
    .toggle, 
 
    [id^=drop] { 
 
    \t display: none; 
 
    } 
 

 
    /* Giving a background-color to the nav container. */ 
 
    nav { 
 
    \t margin:0; 
 
    \t padding: 0; 
 
    \t background-color: #254441; 
 
    } 
 

 
    #logo { 
 
    \t display: block; 
 
    \t padding: 0 30px; 
 
    \t float: left; 
 
    \t font-size:20px; 
 
    \t line-height: 60px; 
 
    } 
 

 
    /* Since we'll have the "ul li" "float:left" 
 
    * we need to add a clear after the container. */ 
 

 
    nav:after { 
 
    \t content:""; 
 
    \t display:table; 
 
    \t clear:both; 
 
    } 
 

 
    /* Removing padding, margin and "list-style" from the "ul", 
 
    * and adding "position:reltive" */ 
 
    nav ul { 
 
    \t float: right; 
 
    \t padding:0; 
 
    \t margin:0; 
 
    \t list-style: none; 
 
    \t position: relative; 
 
    \t } 
 
    \t 
 
    /* Positioning the navigation items inline */ 
 
    nav ul li { 
 
    \t margin: 0px; 
 
    \t display:inline-block; 
 
    \t float: left; 
 
    \t background-color: #254441; 
 
    \t } 
 

 
    /* Styling the links */ 
 
    nav a { 
 
    \t display:block; 
 
    \t padding:14px 20px; \t 
 
    \t color:#FFF; 
 
    \t font-size:17px; 
 
    \t text-decoration:none; 
 
    } 
 

 

 
    nav ul li ul li:hover { background: #000000; } 
 

 
    /* Background color change on Hover */ 
 
    nav a:hover { 
 
    \t background-color: #000000; 
 
    } 
 

 
    /* Hide Dropdowns by Default 
 
    * and giving it a position of absolute */ 
 
    nav ul ul { 
 
     display: none; 
 
     top: 20px; 
 
     padding-top: 20px; 
 
    } 
 
    \t 
 
    /* Display Dropdowns on Hover */ 
 
    nav ul li:hover > ul { 
 
     position: absolute; 
 
     display: block; 
 
    } 
 
    \t 
 
    /* Fisrt Tier Dropdown */ 
 
    nav ul ul li { 
 
    \t width:170px; 
 
    \t float:none; 
 
    \t display:list-item; 
 
    \t position: relative; 
 
    } 
 

 
    /* Second, Third and more Tiers \t 
 
    * We move the 2nd and 3rd etc tier dropdowns to the left 
 
    * by the amount of the width of the first tier. 
 
    */ 
 
    nav ul ul ul li { 
 
    \t position: relative; 
 
    \t top:-60px; 
 
    \t /* has to be the same number as the "width" of "nav ul ul li" */ 
 
    \t left:170px; 
 
    } 
 

 
    \t 
 
    /* Change ' +' in order to change the Dropdown symbol */ 
 
    li > a:after { content: ' +'; } 
 
    li > a:only-child:after { content: ''; } 
 

 

 
    /* Media Queries 
 
    --------------------------------------------- */ 
 

 
    @media all and (max-width : 768px) { 
 

 
    \t #logo { 
 
    \t \t display: block; 
 
    \t \t padding: 0; 
 
    \t \t width: 100%; 
 
    \t \t text-align: center; 
 
    \t \t float: none; 
 
    \t } 
 

 
    \t nav { 
 
    \t \t margin: 0; 
 
    \t } 
 

 
    \t /* Hide the navigation menu by default */ 
 
    \t /* Also hide the */ 
 
    \t .toggle + a, 
 
    \t .menu { 
 
    \t \t display: none; 
 
    \t } 
 

 
    \t /* Stylinf the toggle lable */ 
 
    \t .toggle { 
 
    \t \t display: block; 
 
    \t \t background-color: #254441; 
 
    \t \t padding:14px 20px; \t 
 
    \t \t color:#FFF; 
 
    \t \t font-size:17px; 
 
    \t \t text-decoration:none; 
 
    \t \t border:none; 
 
    \t } 
 

 
    \t .toggle:hover { 
 
    \t \t background-color: #000000; 
 
    \t } 
 

 
    \t /* Display Dropdown when clicked on Parent Lable */ 
 
    \t [id^=drop]:checked + ul { 
 
    \t \t display: block; 
 
    \t } 
 

 
    \t /* Change menu item's width to 100% */ 
 
    \t nav ul li { 
 
    \t \t display: block; 
 
    \t \t width: 100%; 
 
    \t \t } 
 

 
    \t nav ul ul .toggle, 
 
    \t nav ul ul a { 
 
    \t \t padding: 0 40px; 
 
    \t } 
 

 
    \t nav ul ul ul a { 
 
    \t \t padding: 0 80px; 
 
    \t } 
 

 
    \t nav a:hover, 
 
     \t nav ul ul ul a { 
 
    \t \t background-color: #000000; 
 
    \t } 
 
     
 
    \t nav ul li ul li .toggle, 
 
    \t nav ul ul a, 
 
     nav ul ul ul a{ 
 
    \t \t padding:14px 20px; \t 
 
    \t \t color:#FFF; 
 
    \t \t font-size:17px; 
 
    \t } 
 
     
 
     
 
    \t nav ul li ul li .toggle, 
 
    \t nav ul ul a { 
 
    \t \t background-color: #212121; 
 
    \t } 
 

 
    \t /* Hide Dropdowns by Default */ 
 
    \t nav ul ul { 
 
    \t \t float: none; 
 
    \t \t position:static; 
 
    \t \t color: #ffffff; 
 
    \t \t /* has to be the same number as the "line-height" of "nav a" */ 
 
    \t } 
 
    \t \t 
 
    \t /* Hide menus on hover */ 
 
    \t nav ul ul li:hover > ul, 
 
    \t nav ul li:hover > ul { 
 
    \t \t display: none; 
 
    \t } 
 
    \t \t 
 
    \t /* Fisrt Tier Dropdown */ 
 
    \t nav ul ul li { 
 
    \t \t display: block; 
 
    \t \t width: 100%; 
 
    \t } 
 

 
    \t nav ul ul ul li { 
 
    \t \t position: static; 
 
    \t \t /* has to be the same number as the "width" of "nav ul ul li" */ 
 

 
    \t } 
 
     
 
     
 
     /*to overwrite desktop default behaviour*/ 
 
     nav ul li > ul, nav ul li:hover > ul { 
 
     position: relative; 
 
     top: 0; 
 
     padding-top: 0; 
 
     } 
 
     
 

 

 
    } 
 

 
    @media all and (max-width : 330px) { 
 

 
    \t nav ul li { 
 
    \t \t display:block; 
 
    \t \t width: 94%; 
 
    \t } 
 

 
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
    <body> 
 
     <nav> 
 
      <div id="logo">Your Logo here</div> 
 

 
      <label for="drop" class="toggle">Menu</label> 
 
      <input type="checkbox" id="drop" /> 
 
       <ul class="menu"> 
 
        <li><a href="#">Home</a></li> 
 
        <li> 
 
         <!-- First Tier Drop Down --> 
 
         <label for="drop-1" class="toggle">WordPress +</label> 
 
         <a href="#">WordPress</a> 
 
         <input type="checkbox" id="drop-1"/> 
 
         <ul> 
 
          <li><a href="#">Themes and stuff</a></li> 
 
          <li><a href="#">Plugins</a></li> 
 
          <li><a href="#">Tutorials</a></li> 
 
         </ul> 
 

 
        </li> 
 
        <li> 
 

 
        <!-- First Tier Drop Down --> 
 
        <label for="drop-2" class="toggle">Web Design +</label> 
 
        <a href="#">Web Design</a> 
 
        <input type="checkbox" id="drop-2"/> 
 
        <ul> 
 
         <li><a href="#">Resources</a></li> 
 
         <li><a href="#">Links</a></li> 
 
         <li> 
 
          
 
         <!-- Second Tier Drop Down -->   
 
         <label for="drop-3" class="toggle">Tutorials +</label> 
 
         <a href="#">Tutorials</a>   
 
         <input type="checkbox" id="drop-3"/> 
 

 
         <ul> 
 
          <li><a href="#">HTML/CSS</a></li> 
 
          <li><a href="#">jQuery</a></li> 
 
          <li><a href="#">Other</a></li> 
 
         </ul> 
 
         </li> 
 
        </ul> 
 
        </li> 
 
        <li><a href="#">Graphic Design</a></li> 
 
        <li><a href="#">Inspiration</a></li> 
 
        <li><a href="#">Contact</a></li> 
 
        <li><a href="#">About</a></li> 
 
       </ul> 
 
      </nav>

Prost

+0

ich das geändert, aber noch nicht die unteren Drop-Down-Optionen auswählen, weiß nicht, was möglicherweise die Ursache sein könnte. – gabogabans

+0

Versucht eine niedrigere Zahl als 40px? Versuchen Sie Null, um mit – Syfer

+0

zu beginnen Versucht oben: 0px und oben: 100% und immer noch nichts. Hier ist etwas Wackeliges, es ist so, als würden die Dropdowns nicht ausgewählt werden. – gabogabans

0

Dies liegt daran, Sie Ihre Fallposition weit unter dem Hover-Zustand Ihrer Navigation. Statt

von
nav ul ul { 
    display: none; 
    position: absolute; 
    top: 60px; 
} 

nav ul li:hover > ul { 
    display: inherit; 
} 

try Änderung:

nav ul ul { 
    display: none; 
    top: 40px; 
    padding-top: 20px; 
} 

nav ul li:hover > ul { 
    position: absolute; 
    display: block; 
} 

Um Stil für mobile Navigation, überschreibt das Standardverhalten Desktop

@media all and (max-width : 768px) { 
    nav ul li:hover > ul { 
    position: relative; 
    top: 0; 
    padding-top: 0; 
    } 
} 

Beispiel:

$('.handle').on('click', function(){ 
 
     $('nav ul').toggleClass('showing'); 
 
    });
body { 
 
\t margin: 0; 
 
\t padding: 0; 
 
\t font-family: sans-serif; 
 
} 
 
.toggle, 
 
[id^=drop] { 
 
\t display: none; 
 
} 
 

 
/* Giving a background-color to the nav container. */ 
 
nav { 
 
\t margin:0; 
 
\t padding: 0; 
 
\t background-color: #254441; 
 
} 
 

 
#logo { 
 
\t display: block; 
 
\t padding: 0 30px; 
 
\t float: left; 
 
\t font-size:20px; 
 
\t line-height: 60px; 
 
} 
 

 
/* Since we'll have the "ul li" "float:left" 
 
* we need to add a clear after the container. */ 
 

 
nav:after { 
 
\t content:""; 
 
\t display:table; 
 
\t clear:both; 
 
} 
 

 
/* Removing padding, margin and "list-style" from the "ul", 
 
* and adding "position:reltive" */ 
 
nav ul { 
 
\t float: right; 
 
\t padding:0; 
 
\t margin:0; 
 
\t list-style: none; 
 
\t position: relative; 
 
\t } 
 
\t 
 
/* Positioning the navigation items inline */ 
 
nav ul li { 
 
\t margin: 0px; 
 
\t display:inline-block; 
 
\t float: left; 
 
\t background-color: #254441; 
 
\t } 
 

 
/* Styling the links */ 
 
nav a { 
 
\t display:block; 
 
\t padding:14px 20px; \t 
 
\t color:#FFF; 
 
\t font-size:17px; 
 
\t text-decoration:none; 
 
} 
 

 

 
nav ul li ul li:hover { background: #000000; } 
 

 
/* Background color change on Hover */ 
 
nav a:hover { 
 
\t background-color: #000000; 
 
} 
 

 
/* Hide Dropdowns by Default 
 
* and giving it a position of absolute */ 
 
nav ul ul { 
 
    display: none; 
 
    top: 40px; 
 
    padding-top: 20px; 
 
} 
 
\t 
 
/* Display Dropdowns on Hover */ 
 
nav ul li:hover > ul { 
 
    position: absolute; 
 
    display: block; 
 
} 
 
\t 
 
/* Fisrt Tier Dropdown */ 
 
nav ul ul li { 
 
\t width:170px; 
 
\t float:none; 
 
\t display:list-item; 
 
\t position: relative; 
 
} 
 

 
/* Second, Third and more Tiers \t 
 
* We move the 2nd and 3rd etc tier dropdowns to the left 
 
* by the amount of the width of the first tier. 
 
*/ 
 
nav ul ul ul li { 
 
\t position: relative; 
 
\t top:-60px; 
 
\t /* has to be the same number as the "width" of "nav ul ul li" */ 
 
\t left:170px; 
 
} 
 

 
\t 
 
/* Change ' +' in order to change the Dropdown symbol */ 
 
li > a:after { content: ' +'; } 
 
li > a:only-child:after { content: ''; } 
 

 

 
/* Media Queries 
 
--------------------------------------------- */ 
 

 
@media all and (max-width : 768px) { 
 

 
\t #logo { 
 
\t \t display: block; 
 
\t \t padding: 0; 
 
\t \t width: 100%; 
 
\t \t text-align: center; 
 
\t \t float: none; 
 
\t } 
 

 
\t nav { 
 
\t \t margin: 0; 
 
\t } 
 

 
\t /* Hide the navigation menu by default */ 
 
\t /* Also hide the */ 
 
\t .toggle + a, 
 
\t .menu { 
 
\t \t display: none; 
 
\t } 
 

 
\t /* Stylinf the toggle lable */ 
 
\t .toggle { 
 
\t \t display: block; 
 
\t \t background-color: #254441; 
 
\t \t padding:14px 20px; \t 
 
\t \t color:#FFF; 
 
\t \t font-size:17px; 
 
\t \t text-decoration:none; 
 
\t \t border:none; 
 
\t } 
 

 
\t .toggle:hover { 
 
\t \t background-color: #000000; 
 
\t } 
 

 
\t /* Display Dropdown when clicked on Parent Lable */ 
 
\t [id^=drop]:checked + ul { 
 
\t \t display: block; 
 
\t } 
 

 
\t /* Change menu item's width to 100% */ 
 
\t nav ul li { 
 
\t \t display: block; 
 
\t \t width: 100%; 
 
\t \t } 
 

 
\t nav ul ul .toggle, 
 
\t nav ul ul a { 
 
\t \t padding: 0 40px; 
 
\t } 
 

 
\t nav ul ul ul a { 
 
\t \t padding: 0 80px; 
 
\t } 
 

 
\t nav a:hover, 
 
    \t nav ul ul ul a { 
 
\t \t background-color: #000000; 
 
\t } 
 
    
 
\t nav ul li ul li .toggle, 
 
\t nav ul ul a, 
 
    nav ul ul ul a{ 
 
\t \t padding:14px 20px; \t 
 
\t \t color:#FFF; 
 
\t \t font-size:17px; 
 
\t } 
 
    
 
    
 
\t nav ul li ul li .toggle, 
 
\t nav ul ul a { 
 
\t \t background-color: #212121; 
 
\t } 
 

 
\t /* Hide Dropdowns by Default */ 
 
\t nav ul ul { 
 
\t \t float: none; 
 
\t \t position:static; 
 
\t \t color: #ffffff; 
 
\t \t /* has to be the same number as the "line-height" of "nav a" */ 
 
\t } 
 
\t \t 
 
\t /* Hide menus on hover */ 
 
\t nav ul ul li:hover > ul, 
 
\t nav ul li:hover > ul { 
 
\t \t display: none; 
 
\t } 
 
\t \t 
 
\t /* Fisrt Tier Dropdown */ 
 
\t nav ul ul li { 
 
\t \t display: block; 
 
\t \t width: 100%; 
 
\t } 
 

 
\t nav ul ul ul li { 
 
\t \t position: static; 
 
\t \t /* has to be the same number as the "width" of "nav ul ul li" */ 
 

 
\t } 
 
    
 
    
 
    /*to overwrite desktop default behaviour*/ 
 
    nav ul li > ul, nav ul li:hover > ul { 
 
    position: relative; 
 
    top: 0; 
 
    padding-top: 0; 
 
    } 
 
    
 

 

 
} 
 

 
@media all and (max-width : 330px) { 
 

 
\t nav ul li { 
 
\t \t display:block; 
 
\t \t width: 94%; 
 
\t } 
 

 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
 
<body> 
 
    <nav> 
 
     <div id="logo">Your Logo here</div> 
 

 
     <label for="drop" class="toggle">Menu</label> 
 
     <input type="checkbox" id="drop" /> 
 
      <ul class="menu"> 
 
       <li><a href="#">Home</a></li> 
 
       <li> 
 
        <!-- First Tier Drop Down --> 
 
        <label for="drop-1" class="toggle">WordPress +</label> 
 
        <a href="#">WordPress</a> 
 
        <input type="checkbox" id="drop-1"/> 
 
        <ul> 
 
         <li><a href="#">Themes and stuff</a></li> 
 
         <li><a href="#">Plugins</a></li> 
 
         <li><a href="#">Tutorials</a></li> 
 
        </ul> 
 

 
       </li> 
 
       <li> 
 

 
       <!-- First Tier Drop Down --> 
 
       <label for="drop-2" class="toggle">Web Design +</label> 
 
       <a href="#">Web Design</a> 
 
       <input type="checkbox" id="drop-2"/> 
 
       <ul> 
 
        <li><a href="#">Resources</a></li> 
 
        <li><a href="#">Links</a></li> 
 
        <li> 
 
         
 
        <!-- Second Tier Drop Down -->   
 
        <label for="drop-3" class="toggle">Tutorials +</label> 
 
        <a href="#">Tutorials</a>   
 
        <input type="checkbox" id="drop-3"/> 
 

 
        <ul> 
 
         <li><a href="#">HTML/CSS</a></li> 
 
         <li><a href="#">jQuery</a></li> 
 
         <li><a href="#">Other</a></li> 
 
        </ul> 
 
        </li> 
 
       </ul> 
 
       </li> 
 
       <li><a href="#">Graphic Design</a></li> 
 
       <li><a href="#">Inspiration</a></li> 
 
       <li><a href="#">Contact</a></li> 
 
       <li><a href="#">About</a></li> 
 
      </ul> 
 
     </nav>

+0

die Polsterung rückgängig macht die Änderungen der Spitze ich denke, versuchte es aber immer noch nicht lassen Sie die unteren Dropdown-Menüs auswählen. – gabogabans

+0

Ich habe meinen Code aktualisiert, einschließlich des Snippets. – Vincent1989

0

Sie haben diese Regel gibt es in:

nav ul ul { 
    display: none; 
    position: absolute; 
    /* has to be the same number as the "line-height" of "nav a" */ 
    top: 60px; 
} 

Wenn Sie top: 60px; zu top: 40px; ändern, wird es nach oben nahe werden wählbar enought. Hier

ist eine Geige, wo es funktioniert: http://jsfiddle.net/hm41j6u1/1/

Verwandte Themen