/    Sign up×
Community /Pin to ProfileBookmark

Tabbing through sub-menus

Hello I have a quick menu bar that I am trying to make accessible.
When I tab it works but on a menu that has sub-menu it dosnt go down the submenu… How do I fix this?

[code]<!DOCTYPE html>
<html lang=”en”>
<head>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>
<style>

body {

background: #212121;
font-size:22px;
line-height: 32px;
color: #ffffff;
margin: 0;
padding: 0;
word-wrap:break-word !important;
font-family: ‘Open Sans’, sans-serif;
}

h1 {
font-size: 60px;
text-align: center;
color: #FFF;
}

h3 {
font-size: 30px;
line-height: 34px;
text-align: center;
color: #FFF;
}

h3 a {
color: #FFF;
}

a {
color: #FFF;
}

h1 {
margin-top: 100px;
text-align:center;
font-size:60px;
line-height: 70px;
font-family: ‘Bree Serif’, ‘serif’;
}

#container {
margin: 0 auto;
max-width: 890px;
}

p {
text-align: center;
}

.toggle,
[id^=drop] {
display: none;
}

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

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

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

nav:after {
content:””;
display:table;
clear:both;
}

/* Removing padding, margin and “list-style” from the “ul”,
* and adding “position:reltive” */
nav ul {
float: right;
padding:0;
margin:0;
list-style: none;
position: relative;
}

/* Positioning the navigation items inline */
nav ul li {
margin: 0px;
display:inline-block;
float: left;
background-color: #254441;
}

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

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

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

/* Hide Dropdowns by Default
* and giving it a position of absolute */
nav ul ul {
display: none;
position: absolute;
/* has to be the same number as the “line-height” of “nav a” */
top: 60px;
}

/* Display Dropdowns on Hover */
nav ul li:hover > ul {
display:inherit;
}

/* Fisrt Tier Dropdown */
nav ul ul li {
width:170px;
float:none;
display:list-item;
position: relative;
}

/* Second, Third and more Tiers
* 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 {
position: relative;
top:-60px;
/* has to be the same number as the “width” of “nav ul ul li” */
left:170px;
}

/* Media Queries
——————————————— */

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

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

nav {
margin: 0;
}

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

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

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

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

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

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

nav a:hover,
nav ul ul ul a {
background-color: #000000;
}

nav ul li ul li .toggle,
nav ul ul a,
nav ul ul ul a{
padding:14px 20px;
color:#FFF;
font-size:17px;
}

nav ul li ul li .toggle,
nav ul ul a {
background-color: #212121;
}

/* Hide Dropdowns by Default */
nav ul ul {
float: none;
position:static;
color: #ffffff;
/* has to be the same number as the “line-height” of “nav a” */
}

/* Hide menus on hover */
nav ul ul li:hover > ul,
nav ul li:hover > ul {
display: none;
}

/* Fisrt Tier Dropdown */
nav ul ul li {
display: block;
width: 100%;
}

nav ul ul ul li {
position: static;
/* has to be the same number as the “width” of “nav ul ul li” */

}

}

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

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

}
</style>
<title>Menu Navigation Test</title>
</head>
<body>
<nav>
<div id=”logo”>Syracuse University Libraries</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”>About</label>
<a href=”#”>About</a>

<ul>
<li><a href=”#”>Departments</a></li>
<li><a href=”#”>News</a></li>
</ul>

</li>
<li>
<!– First Tier Drop Down –>
<label for=”drop-2″ class=”toggle”>Rooms</label>
<a href=”#”>Rooms</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”>Spaces</label>
<a href=”#”>Rooms (Dropdown)</a>
<input type=”checkbox” id=”drop-3″/>
<ul>
<li><a href=”#”>Learning Commons</a></li>
<li><a href=”#”>Locations</a></li>
<li><a href=”#”>Reserve a Room</a></li>
</ul>
</li>
</ul>
</li>
<li><a href=”#”>Special Collections</a></li>
<li><a href=”#”>Giving</a></li>
<li><a href=”#”>More</a></li>
</ul>
</nav>

<!– Sample Text –>
<h1><p>This is a Generic Hierarchical Menu Navigation.</p></h1>
<p>This is a Generic Hierarchical Menu Navigation.</p>
<p>This is a Generic Hierarchical Menu Navigation.</p>

<footer>

<p>Contact information: <a href=”mailto:[email protected]”>
[email protected]</a>.</p>
</footer>
</body>

</html>
[/code]

to post a comment
HTML

18 Comments(s)

Copy linkTweet thisAlerts:
@soupiiauthorJan 22.2020 — anybody have a idea? Thank you.
Copy linkTweet thisAlerts:
@SempervivumJan 22.2020 — Check if tabindex can help your

https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
Copy linkTweet thisAlerts:
@soupiiauthorJan 22.2020 — How would I add this tabindex code to my code above?
Copy linkTweet thisAlerts:
@soupiiauthorJan 22.2020 — I tried to follow the steps but no luck.. its still not tabbing through the dropdown
Copy linkTweet thisAlerts:
@soupiiauthorJan 23.2020 — No luck so far... I tried to tabindex but it didnt work.
Copy linkTweet thisAlerts:
@SempervivumJan 23.2020 — My bad, the reason that tabbing into the submenues doesn't work is that they are hidden initially. Therefore adding tabindex will not help.

As a first approach I added this CSS:
nav ul li a:focus~ul {
display: block;
}

This makes the submenu visible when the top item gets focus. But unfortunately the top item looses focus again when tabbing to the next item and disappears.

So far I don't know how to fix this issue by pure CSS. Would require some javascript.
Copy linkTweet thisAlerts:
@soupiiauthorJan 23.2020 — Thank you, but I got that part, how would I make it so the tab goes down the submenu and not just let it show.. currently it goes to the next menu to the right instead of the down the dropdown menu... what javascript would i add. thank you so much for your time
Copy linkTweet thisAlerts:
@SempervivumJan 23.2020 — I figured out this javascript:
&lt;script&gt;
let timer = null;
const links = document.querySelectorAll('nav ul li a');
const uls = document.querySelectorAll('nav ul ul');
for (let i = 0; i &lt; links.length; i++) {
const thelink = links[i];
const parentli = thelink.parentNode;
const childul = parentli.querySelector('ul');
thelink.addEventListener('focus', function () {
if (childul) childul.style.display = 'inherit';
});
thelink.addEventListener('blur', function () {
timer = setTimeout(function () {
let ele = thelink;
while (ele.parentNode.tagName != 'NAV') {
if (ele.tagName == 'UL' &amp;&amp; !ele.querySelector('a:focus')) {
ele.style.display = 'none';
}
ele = ele.parentNode;
}
}, 50);
});
}
&lt;/script&gt;

and modified the CSS:
/* Display Dropdowns on Hover */
nav ul li:hover&gt;ul {
display: inherit !important;
}

<i> </i> /* nav ul li a:focus~ul {
<i> </i> display: block;
<i> </i> } */

(added !important and removed the CSS I posted above)

Applied all of this to the HTML [b]without[/b] the tabindex attributes and it works fine.

However I'm not completely satisfied: Use of setTimeout is ugly but I didn't find a better solution.
Copy linkTweet thisAlerts:
@soupiiauthorJan 23.2020 — Thank you so much, can you explain a little bit what the javascript is doing.?
Copy linkTweet thisAlerts:
@soupiiauthorJan 23.2020 — Also couldnt i have done it by just adding this to the css?

li ul {display: none;}

li:focus-within ul,

li:hover ul {display: block;}
Copy linkTweet thisAlerts:
@SempervivumJan 23.2020 — I added some comments in order to explain what the code does:
&lt;script&gt;
// get all the links or a-tags in the menu
const links = document.querySelectorAll('nav ul li a');
// loop through all links
for (let i = 0; i &lt; links.length; i++) {
// the current link
const thelink = links[i];
// the parent node which is an li
parentli = thelink.parentNode;
// the ul element which is a child of the li
const childul = parentli.querySelector('ul');
// add an eventlistener for "onfocus" to the link
thelink.addEventListener('focus', function () {
// when the link gets focus we have to make the child menu visible
if (childul) childul.style.display = 'inherit';
});
// a bit more complex: when a link looses focus we have to
// hide the parent ul
thelink.addEventListener('blur', function () {
// hiding the parent ul should be done if no link in the tree below
// has got focus after tabbing. in order to be shure that the next
// link has focus after the previous one has lost it, we have to wait
// for a moment (50 ms).
setTimeout(function () {
// we step upwards in the tree. when we find an ul element we check
// if no link below has focus. if so we hide the ul element.
// the topmost ul must not be made invisible as the top menu
// should be visible always.
let ele = thelink;
while (ele.parentNode.tagName != 'NAV') {
if (ele.tagName == 'UL' &amp;&amp; !ele.querySelector('a:focus')) {
ele.style.display = 'none';
}
ele = ele.parentNode;
}
}, 50);
});
}
&lt;/script&gt;


However it seems to me that you have found the missing link or easier solution by using :focus-within. Well done!
Copy linkTweet thisAlerts:
@soupiiauthorJan 24.2020 — Thank you for your help. Now i just have to figure out how to make the menu "sticky" so it stays fixed when i scroll on the page
Copy linkTweet thisAlerts:
@SempervivumJan 24.2020 — Check if this demo helps you:

https://jsfiddle.net/Sempervivum/d4ao5kbh/5/
Copy linkTweet thisAlerts:
@RollwealthgroupJan 25.2020 — I need a partner on a project on my mind. I have written it down but don't have Web design knowledge to follow up on it.

Most people I have talked with are not helpful.

Help me.
Copy linkTweet thisAlerts:
@soupiiauthorJan 27.2020 — @Sempervivum#1613570 I tried the pages code and didnt work.. this is my current code

&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
&lt;!--Author URL: https://codepen.io/andornagy/pen/RNeydj
Description: A Generic Hierarchical Menu Navigation
Version: 1--&gt;
&lt;style&gt;

body {
<br/>
<i> </i>background: #212121;
<i> </i>font-size:22px;
<i> </i>line-height: 32px;
<i> </i>color: #ffffff;
<i> </i>margin: 0;
<i> </i>padding: 0;
<i> </i>word-wrap:break-word !important;
<i> </i>font-family: 'Open Sans', sans-serif;
<i> </i>}

h1 {
font-size: 60px;
text-align: center;
color: #FFF;
}

h3 {
font-size: 30px;
line-height: 34px;
text-align: center;
color: #FFF;
}

h3 a {
color: #FFF;
}

a {
color: #FFF;
}

h1 {
margin-top: 100px;
text-align:center;
font-size:60px;
line-height: 70px;
font-family: 'Bree Serif', 'serif';
}

#container {
margin: 0 auto;
max-width: 890px;
}

p {
text-align: center;
}

.toggle,
[id^=drop] {
display: none;
}

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

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

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

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

/* Removing padding, margin and "list-style" from the "ul",
* and adding "position:reltive" */
nav ul {
float: right;
padding:0;
margin:0;
list-style: none;
position: relative;
}

/* Positioning the navigation items inline */
nav ul li {
margin: 0px;
display:inline-block;
float: left;
background-color: #E64A19;
}

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


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

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

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

/* Display Dropdowns on Hover */
nav ul li:hover &gt; ul {
display:inherit;
}

/* Fisrt Tier Dropdown */
nav ul ul li {
width:170px;
float:none;
display:list-item;
position: relative;
}

/* Second, Third and more Tiers
* 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 {
position: relative;
top:-60px;
/* has to be the same number as the "width" of "nav ul ul li" */
left:170px;
}
nav ul li a:focus~ul {
display: block;
}
/* Display Dropdowns on Hover */
nav ul li:hover&gt;ul {
display: inherit !important;
}
li ul {display: none;}

li:focus-within ul,
li:hover ul {display: block;}
/* nav ul li a:focus~ul {
display: block;
} */
<br/>
<i> </i>
/* Media Queries

--------------------------------------------- */

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

<i> </i>#logo {
<i> </i> display: block;
<i> </i> padding: 0;
<i> </i> width: 100%;
<i> </i> text-align: center;
<i> </i> float: none;
<i> </i>}

<i> </i>nav {
<i> </i> margin: 0;
<i> </i>}

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

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

<i> </i>.toggle:hover {
<i> </i> background-color: #000000;
<i> </i>}


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

<i> </i>nav ul ul .toggle,
<i> </i>nav ul ul a {
<i> </i> padding: 0 40px;
<i> </i>}

<i> </i>nav ul ul ul a {
<i> </i> padding: 0 80px;
<i> </i>}

<i> </i>nav a:hover,
<i> </i>nav ul ul ul a {
<i> </i> background-color: #000000;
<i> </i>}

<i> </i>nav ul li ul li .toggle,
<i> </i>nav ul ul a,
nav ul ul ul a{
padding:14px 20px;
color:#FFF;
font-size:17px;
}
<br/>
<br/>
<i> </i>nav ul li ul li .toggle,
<i> </i>nav ul ul a {
<i> </i> background-color: #212121;
<i> </i>}

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

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

<i> </i>}

}

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

<i> </i>nav ul li {
<i> </i> display:block;
<i> </i> width: 94%;
<i> </i>}

}
&lt;/style&gt;
&lt;link href="assets/css/panam.css" rel="stylesheet"/&gt; <br/>
&lt;title&gt;Menu Navigation Test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;nav&gt;
&lt;div id="logo"&gt;Syracuse University Libraries&lt;/div&gt;

<i> </i> &lt;label for="drop" class="toggle"&gt;Menu&lt;/label&gt;
<i> </i> &lt;input type="checkbox" id="drop" /&gt;
<i> </i> &lt;ul class="menu"&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;
<i> </i> &lt;!-- First Drop Down --&gt;
<i> </i> &lt;label for="drop-1" class="toggle"&gt;About&lt;/label&gt;
<i> </i> &lt;a href="#"&gt;About&lt;/a&gt;
<i> </i>
<i> </i> &lt;ul&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Departments&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;News&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;/ul&gt;

<i> </i> &lt;/li&gt;
<i> </i> &lt;li&gt;
<i> </i> &lt;!-- First Drop Down --&gt;
<i> </i> &lt;label for="drop-2" class="toggle"&gt;Rooms&lt;/label&gt;
<i> </i> &lt;a href="#"&gt;Rooms&lt;/a&gt;
<i> </i> &lt;input type="checkbox" id="drop-2"/&gt;
<i> </i> &lt;ul&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Resources&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Links&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;
<i> </i> &lt;!-- Second Drop Down --&gt;
<i> </i> &lt;label for="drop-3" class="toggle"&gt;Spaces&lt;/label&gt;
<i> </i> &lt;a href="#"&gt;Rooms&lt;/a&gt;
<i> </i> &lt;input type="checkbox" id="drop-3"/&gt;
<i> </i> &lt;!--&lt;ul&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Learning Commons&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Locations&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Reserve a Room&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;/ul&gt;--&gt;
<i> </i> &lt;/li&gt;
<i> </i> &lt;/ul&gt;
<i> </i> &lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Special Collections&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Giving&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;More&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;/ul&gt;
<i> </i> &lt;/nav&gt;
<i> </i>
&lt;!-- Sample Text --&gt;
&lt;h1&gt;&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;&lt;/h1&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;




<i> </i> &lt;nav&gt;&lt;footer&gt;

Copyright © 2020 Syracuse University Libraries
&lt;/footer&gt; &lt;/nav&gt;
&lt;!-- Core Javascript Bottom --&gt;
&lt;script src="/assets/plugins/jquery-1.12.3.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/assets/plugins/bootstrap/js/bootstrap-3.3.7.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/assets/plugins/bootstrap-hover-dropdown.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/assets/plugins/bootstrap-hover-dropdown.min.js" type="text/javascript"&gt;&lt;/script&gt; <br/>
&lt;script src="/assets/plugins/back-to-top.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/assets/js/main.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/assets/js/local.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;/body&gt;


&lt;/html&gt;
Copy linkTweet thisAlerts:
@soupiiauthorJan 27.2020 — Thank you so much @Sempervivum and @Rollwealthgroup message me if i can help
Copy linkTweet thisAlerts:
@soupiiauthorFeb 05.2020 — @Sempervivum#1613570

I am trying to have my "about" and "rooms" dropdown to be able to only expand when clicked on and displaying a small arrow similar https://www.syracuse.edu/ in their "Info For" dropdown. When tabbing through it can work as is.

Also I noticed that in when tabbing through the menu and tabbing backwards (shift+tab) it dosnt go back up the dropdown why is that? Another issue is when I shrink the window to display the quick menu and tabbing through the menu it skips the about and rooms link why is that?

Here is the code i have so far, thank you.
&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
&lt;!--Author URL: https://codepen.io/andornagy/pen/RNeydj
Description: A Generic Hierarchical Menu Navigation
Version: 1--&gt;
&lt;style&gt;
/* CSS Document */
body {
background: #212121;
font-size:22px;
line-height: 32px;
color: #ffffff;
margin: 0;
padding: 0;
word-wrap:break-word !important;
font-family: 'Open Sans', sans-serif;
<br/>
<i> </i> height: 100vh; /*100% of the viewport*/
<i> </i> display: flex;
<i> </i> flex-direction: column;
<i> </i>}
<i> </i>.scroll {
<i> </i> overflow-y: scroll;
} <br/>
h1 {
font-size: 60px;
text-align: center;
color: #FFF;
}

h3 {
font-size: 30px;
line-height: 34px;
text-align: center;
color: #FFF;
}

h3 a {
color: #FFF;
}

a {
color: #FFF;
}

h1 {
margin-top: 100px;
text-align:center;
font-size:60px;
line-height: 70px;
font-family: 'Bree Serif', 'serif';
}

#container {
margin: 0 auto;
max-width: 890px;
}

p {
text-align: center;
}

.toggle,
[id^=drop] {
display: none;
}

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

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

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

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

/* Removing padding, margin and "list-style" from the "ul",
* and adding "position:reltive" */
nav ul {
float: right;
padding:0;
margin:0;
list-style: none;
position: relative;
}

/* Positioning the navigation items inline */
nav ul li {
margin: 0px;
display:inline-block;
float: left;
background-color: #E64A19;
}

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


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

/* Background color change on Hover */
nav a:hover {
background-color: #000000;
text-decoration: underline;

}

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

/* Display Dropdowns on Hover */
nav ul li:hover &gt; ul {
display:inherit;
<br/>
}

/* Fisrt Tier Dropdown */
nav ul ul li {
width:170px;
float:none;
display:list-item;
position: relative;
}

/* Second, Third and more Tiers
* 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 {
position: relative;
top:-60px;
/* has to be the same number as the "width" of "nav ul ul li" */
left:170px;
}


/* Making dropdowns tabbable */
li ul {display: none;}

li:focus-within ul,
li:hover ul {display: block;}

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

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

<i> </i>#logo {
<i> </i> display: block;
<i> </i> padding: 0;
<i> </i> width: 100%;
<i> </i> text-align: center;
<i> </i> float: none;
<i> </i>}

<i> </i>nav {
<i> </i> margin: 0;
<i> </i>}

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

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

<i> </i>.toggle:hover {
<i> </i> background-color: #000000;
<i> </i>}

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

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

<i> </i>nav ul ul .toggle,
<i> </i>nav ul ul a {
<i> </i> padding: 0 40px;
<i> </i>}

<i> </i>nav ul ul ul a {
<i> </i> padding: 0 80px;
<i> </i>}

<i> </i>nav a:hover,
<i> </i>nav ul ul ul a {
<i> </i> background-color: #000000;
<i> </i>}

<i> </i>nav ul li ul li .toggle,
<i> </i>nav ul ul a,
nav ul ul ul a{
padding:14px 20px;
color:#FFF;
font-size:17px;
}
<br/>
<br/>
<i> </i>nav ul li ul li .toggle,
<i> </i>nav ul ul a {
<i> </i> background-color: #212121;
<i> </i>}

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

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

<i> </i>}

}

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

<i> </i>nav ul li {
<i> </i> display:block;
<i> </i> width: 94%;
<i> </i>}

}
&lt;/style&gt;
&lt;title&gt;Menu Navigation Test&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;header&gt; &lt;nav&gt;
&lt;div id="logo"&gt;Syracuse University Libraries&lt;/div&gt;

<i> </i> &lt;label for="drop" class="toggle"&gt;Menu&lt;/label&gt;
<i> </i> &lt;input type="checkbox" id="drop" /&gt;
<i> </i> &lt;ul class="menu"&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Home&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;
<i> </i> &lt;!-- First Drop Down --&gt;
<i> </i> &lt;label for="drop-1" class="toggle"&gt;About&lt;/label&gt;
<i> </i> &lt;a href="#"&gt;About&lt;/a&gt;
<i> </i>
<i> </i> &lt;ul&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Departments&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;News&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;/ul&gt;

<i> </i> &lt;/li&gt;
<i> </i> &lt;li&gt;
<i> </i> &lt;!-- First Drop Down --&gt;
<i> </i> &lt;label for="drop-2" class="toggle"&gt;Rooms&lt;/label&gt;
<i> </i> &lt;a href="#"&gt;Rooms&lt;/a&gt;
<i> </i> &lt;input type="checkbox" id="drop-2"/&gt;
<i> </i> &lt;ul&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Resources&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Links&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;
<i> </i> &lt;!-- Second Drop Down --&gt;
<i> </i> &lt;label for="drop-3" class="toggle"&gt;Spaces&lt;/label&gt;
<i> </i> &lt;a href="#"&gt;Rooms&lt;/a&gt;
<i> </i> &lt;input type="checkbox" id="drop-3"/&gt;
<i> </i> &lt;/li&gt;
<i> </i> &lt;/ul&gt;
<i> </i> &lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Special Collections&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;Giving&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;li&gt;&lt;a href="#"&gt;More&lt;/a&gt;&lt;/li&gt;
<i> </i> &lt;/ul&gt;
<i> </i> &lt;/nav&gt;&lt;/header&gt;
<i> </i>
&lt;!-- Sample Text --&gt;
&lt;section class="scroll" id="content"&gt;&lt;h1&gt;&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;&lt;/h1&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;
&lt;p&gt;This is a Generic Hierarchical Menu Navigation.&lt;/p&gt;&lt;/section&gt;
&lt;nav&gt;&lt;footer&gt;

Copyright © 2020 Syracuse University Libraries
&lt;/footer&gt; &lt;/nav&gt;
&lt;!-- Core Javascript Bottom --&gt;
&lt;script src="/assets/plugins/jquery-1.12.3.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="/assets/plugins/back-to-top.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;/body&gt;


&lt;/html&gt;

Copy linkTweet thisAlerts:
@soupiiauthorFeb 06.2020 — any ideas for the fix?
×

Success!

Help @soupii spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...