Drop Down Menu with Sub Menu - html

I am working on a project and I'm struggling with one piece. It may be very simple, but I'm clearly over looking something. My objective is to have a menu and sub-menu populate on a hover over a specific image. When you hover over the image you'll see "categories" and to the right see the "sub-menu" to that category. I am able to get the first category to work, but unable to get any of the subsequent categories to change the "sub-menu" to the right. I've included the code below. Any help would be appreciated - I'm struggling to make this work
Menu Example:
This is my styling css:
/* Dropdown Button */
.dropbtn {
border: none;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
z-index: 1;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
float: right;
position: absolute;
background-image: url(../images/Framework-and-Navigation_03.png);
min-width: 100px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content2{
display: block;
position: relative;
z-index: 1;
color: black;
padding: 12px 16px;
text-decoration: none;
}
.dropdown-content3{
display: block;
position: relative;
z-index: 1;
color: black;
padding: 12px 16px;
text-decoration: none;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content-sub1 {
color: black;
text-decoration: none;
display: none;
z-index: 1;
}
.dropdown-content-sub2 {
color: black;
text-decoration: none;
display: none;
}
.dropdown-content-sub3 {
color: black;
text-decoration: none;
display: none;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: inline-block;}
/* Change the sub menu */
.dropdown-content1:hover .dropdown-content-sub1 {display: block;}
.dropdown-content2:hover .dropdown-content-sub2 {display: inline-block;}
This is my menu/submenu test:
<div class="dropdown">
<center>
<input type="image" class="dropbtn" src="images/menu_07.png"/>
</center>
<div class="dropdown-content">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="158">
<div class="dropdown-content1">Link 1</div>
<div>Link 2</div>
<div>Link 3</div>
</td>
<td class="dropdown-content-sub1" valign="top"><div>
Test
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>

See if this solves your problem :)
/* Dropdown Button */
html,
body {
font-family: arial;
padding: 0;
margin: 0;
}
a {
padding: 10px;
text-decoration: none;
display: block;
}
.menu-container {
width: 615px;
height: 200px;
background: #eee url("https://images.unsplash.com/photo-1538098269808-2ace9a4d9680?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=2a48defb8057de5b3f79b49b85c173bc&auto=format&fit=crop&w=500&q=60") no-repeat 200px 0;
display: none;
position: absolute;
top: 50px;
left: 0;
box-shadow: 0 0 8px 8px rgba(0, 0, 0, 0.3);
}
ul.menu,
ul.menu ul {
width: 200px;
padding: 0;
margin: 0;
display: none;
flex-direction: column;
}
ul.menu li,
ul.menu ul li {
background: rgba(0, 0, 0, 0.5);
height: 30px;
display: flex;
align-items: center;
}
ul.menu li a,
ul.menu ul li a {
color: white;
margin-bottom: 1px;
}
ul.menu li:hover ul,
ul.menu ul li:hover ul {
display: flex;
}
ul.menu ul {
position: absolute;
margin: 0 0 0 200px;
top: 0;
z-index: 2;
}
/* The container <div> - needed to position the dropdown content */
.nav {
background-color: black;
display: flex;
flex-direction: row;
}
.nav > .nav-item {
height: 30px;
padding: 10px;
margin-right: 2px;
background-color: rgba(255, 255, 255, 0.4);
color: white;
display: flex;
align-items: center;
}
.nav > .nav-item:hover > .menu-container,
.nav > .nav-item:hover > .menu-container > .menu {
display: flex;
}
<div class="nav">
<div class="nav-item" href="">Nav item 1
<div class="menu-container">
<ul class="menu">
<li>Menu item 1 >
<ul>
<li>Sub menu 1 item 1</li>
<li>Sub menu 2 item 2</li>
</ul>
</li>
<li>Menu item 2</li>
<li>Menu item 3 >
<ul>
<li>Sub menu 2 item 1</li>
<li>Sub menu 2 item 2</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="nav-item" href="">Nav item 2</div>
</div>

Related

How to float search icon to the right

How do i float the font awesome search icon to the right next to sign up.
Here is a screenshot of my nav bar, so you know what i am referring too:
https://imgur.com/rE23FfB
I have search the internet for tutorials and they all say to use float: right; but that seems to not work
body {
margin: 0;
padding: 0;
margin-top: 130px;
overflow-x: hidden;
}
.nav-menu a img {
float: left;
margin-left: 10px;
}
.nav-menu ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.9);
margin-top: -130px;
}
.nav-menu li {
float: left;
}
.nav-menu li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.nav-menu li a:hover,
.dropdown:hover .dropbtn {
border-top: 2px solid #ff0000;
}
.nav-menu li.dropdown {
display: inline-block;
}
.nav-menu .dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.nav-menu .dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.nav-menu .dropdown-content a:hover {
background-color: #ff0000;
color: #fff;
}
.nav-menu .dropdown:hover .dropdown-content {
display: block;
}
.nav-menu li.social {
float: right;
}
<div class="nav-menu">
<ul>
<img src="img/logo.jpg" style="width:50px">
<li class="dropdown">
Games
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Crews
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li>Jobs</li>
<li>Photos</li>
<li>Videos</li>
<li>Events</li>
<li>News</li>
<li class="social">
Sign In
Sign Up
<li><i class="fas fa-search"></i></li>
</ul>
The problem is your <li> wrapping the search icon. This is an invalid code. <li> cannot be a children of an <li>. Change it to just an <a> element
body {
margin: 0;
padding: 0;
margin-top: 130px;
overflow-x: hidden;
}
.nav-menu a img {
float: left;
margin-left: 10px;
}
.nav-menu ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.9);
margin-top: -130px;
}
.nav-menu li {
float: left;
}
.nav-menu li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.nav-menu li a:hover,
.dropdown:hover .dropbtn {
border-top: 2px solid #ff0000;
}
.nav-menu li.dropdown {
display: inline-block;
}
.nav-menu .dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.nav-menu .dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.nav-menu .dropdown-content a:hover {
background-color: #ff0000;
color: #fff;
}
.nav-menu .dropdown:hover .dropdown-content {
display: block;
}
.nav-menu li.social {
float: right;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<div class="nav-menu">
<ul>
<li><img src="img/logo.jpg" style="width:50px"></li>
<li class="dropdown">
Games
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Crews
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li>Jobs</li>
<li>Photos</li>
<li>Videos</li>
<li>Events</li>
<li>News</li>
<li class="social">
Sign In
Sign Up
<i class="fas fa-search"></i>
</li>
</ul>
</div>
I know I'm a little late to the question - but I have an improved solution (at least I think so)!
The syntax on the previous answer is still a little incorrect. You should also try to make your dropdowns into nested ul's. :-)
By using the display: flex and align-items: center on the .nav-menu, you will be aligning all the elements up without the use of float (which I tend to avoid anyway as it often makes your code behave like you would not expect).
I've also added margin-left:auto for you on your .social container, it will push all your social to the end of the parent.
EDIT:
If you use border-top: transparent on the menu items, this makes sure that the text doesn't move when you add in a coloured border on :hover - so you're essentially just showing the colour.
html,
body {
margin: 0;
padding: 0;
}
.nav-menu {
display: flex;
align-items: center;
background-color: rgba(0, 0, 0, 0.9);
}
.nav-menu img {
margin: 0 10px;
}
.nav-menu>ul {
list-style-type: none;
margin: 0;
padding: 0;
display: flex;
}
ul.social {
margin-left: auto;
}
.nav-menu li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
border-top: 2px solid transparent;
}
.nav-menu li a:hover,
.dropdown:hover .dropbtn {
border-top: 2px solid #ff0000;
}
.nav-menu li.dropdown {
display: inline-block;
}
.nav-menu .dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
list-style: none;
margin: 0;
padding: 0;
}
.nav-menu .dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.nav-menu .dropdown-content a:hover {
background-color: #ff0000;
color: #fff;
}
.nav-menu .dropdown:hover .dropdown-content {
display: block;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<!-- just for the example -->
<div class="nav-menu">
<img src="img/logo.jpg" style="width:50px">
<ul>
<li class="dropdown">
Games
<ul class="dropdown-content">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</li>
<li class="dropdown">
Crews
<ul class="dropdown-content">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</li>
<li>Jobs</li>
<li>Photos</li>
<li>Videos</li>
<li>Events</li>
<li>News</li>
</ul>
<ul class="social">
<li>Sign In</li>
<li>Sign Up</li>
<li><i class="fas fa-search"></i></li>
</ul>
</div>
You can see the full effect if you view the snippet in full screen.

menu's dropdown occupies only the navbar space + hover not working

I want to create a dropdown nav menu with a modal like box appearing on hover.
Here in my example, Products heading needs to open 4 columns of subheadings that align themselves into a bootstrap like grid.
I am close to the result but I am facing a couple of hurdles: my hover does not seem to work. Also, my subheading appears only within the perimeter of my navbar - whereas I want it to appear a little below the navbar, with some padding.
I looked at these 2 examples but they did not help me:
stackoverflow reference 1
stackoverflow reference 2
Please find the code and guide me in the right direction:
.topnav {
background-color: white;
overflow: hidden;
}
.topnav a {
float: left;
display: block;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
color: grey;
}
.nav {
list-style: none;
display: -webkit-flex;
-webkit-flex-direction: row;
-webkit-justify-content: space-between;
-webkit-flex-wrap: wrap;
}
.nav li:first-child {
margin-right: auto;
}
.nav li {
position: relative;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
position: absolute;
background-color: #f9f9f9;
min-width: 560px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 20;
border: 1px solid white;
padding: 80px;
height: 220px;
}
.dropdown-content ul {
display: block;
}
.arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black;
}
.noshow {
display: none;
}
.dropdown-content:hover .noshow {
display: block
}
.subheading {
font-weight: 700;
}
<nav class="topnav">
<ul class="nav">
<li><a class="active" href="#title"> Title</a></li>
<li>
Products
<div class="dropdown-content arrow-up noshow">
<ul class="column large-3 each-column">
<li class="subheading">subheading</li>
<li>
subheading1
</li>
<li>
subheading2
</li>
<li>
subheading3
</li>
</ul>
</div>
</li>
<li>link2</li>
<li>link3</li>
<li><img src="http://lorempixel.com/30/30/" width="30" height="30" alt="User Account Icon"></li>
</ul>
</nav>
<!DOCTYPE html>
<html>
<head>
<style>
.left_menu {
float: left;
width: 50%;
}
.right_menu {
float: left;
width: 50%;
}
.right_menu ul {
float: right;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: white;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: grey;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
/* background-color: red;*/
/*color: white;*/
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
</style>
</head>
<body>
<div class="left_menu">
<ul>
<li>Title</li>
</ul>
</div>
<div class="right_menu" style="float: left; width: 50%">
<ul>
<li class="dropdown">
Product
<div class="dropdown-content">

Added 2nd css dropdown and it won't line up

I have added a second CSS dropdown menu on my page and it appears on the left of the page. The first one has text center-aligned and everything works great. I added a second one for when an admin is logged in for admin operations.
The text is right-aligned in this menu and the dropdown appears on the left of the screen.
Here is a jsfiddle - https://jsfiddle.net/q0nsrdgo/
Html
<div id="loginbar">
<ul>
<li>Welcome Xenarious | </li><li>Logout |</li>
<li class="dropdown">Admin Controls
<div class="dropdown-content">
Add Customer
Edit Customer
Add Product
Update Product
</div>
|</li> <li>Orders</li>
</ul>
</div>
<header>
<img src="../common/techtitan-title.png">
</header>
<nav>
<ul>
<li>Home</li>
<li class="dropdown"><a href="products.html"
class="dropbtn">Products</a>
<div class="dropdown-content">
<!--Desktops-->
Notebooks
Tablets
Smartphones
</div>
</li>
<li>Services</li>
<li>About Us</li>
<li>Feedback</li>
</ul>
Css
#loginbar {
text-align: right;
background-color: #1D6000;
color: #FFD700;
font-size: 10pt;
z-index: 2;
overflow: auto;
width: 100%;
display: block;
margin: auto;
}
header {
background-color: #1D6000;
margin-bottom: 0;
text-align: center;
z-index: 1;
}
header img {
margin: auto;
text-align:center;
}
nav {
overflow: auto;
width: 100%;
display: block;
margin: auto;
margin-bottom: 20px;
background-color: #1D6000;
text-align: center;
box-shadow: 0px 8px 16px 0px rgba(5,5,5,0.5);
border-bottom: 3px ridge #FFD700;
font-size: 14pt;
}
nav ul, #loginbar ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #1D6000;
}
nav li, #loginbar li {
/*float: left*/
display: inline;
margin: 0;
padding: 0;
}
li a, .dropbtn {
display: inline-block;
color: #FFD700;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color: #FFD700;
color: #1D6000;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #1D6000;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(5,5,5,0.5);
/*z-index: 1;*/
}
.dropdown-content a {
color: #FFD700;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #FFD700;
color: #1D6000;
}
.dropdown:hover .dropdown-content {
display: block;
}
Update your CSS as follows -
nav li, #loginbar li {
display: inline-block;
margin: 0;
padding: 0;
}
Since only your .dropdown class was set to inline-block, the dropdown wasn't being displayed as required.

dropdown box removing styles

I am having a bit of trouble with the drop down box. I want my <a> elements to be without underline and in the middle of the dropdown-content. You can see my code, I want to remove the underlines from the dropdown-content and I want it to be red when it is hovered. However whenever I try to do that, it gives a false defect.
Here is the code. Test it to see the problem logically!
<!DOCTYPE html>
<html>
<head>
<style>
/* Building navigation bar */
ul {
text-align: center;
list-style-type: none;
margin: 0;
padding-bottom: 5px;
background-color: black;
display: block;
}
li a {
text-decoration: none;
padding: 14px 20px;
color: white;
}
li a:hover {
background-color: red;
}
li {
display: inline;
}
/* Building about dropdown and the dropdown content */
.container {
width: 15em;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
text-align: center;
position: absolute;
display: none;
background-color: black;
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
}
</style>
</head>
<body>
<ul>
<li>Home</li>
<li>News</li>
<div class="dropdown">
<li>About</li>
<div class="dropdown-content"><ul>
<a style="text-decoration = none;" href="#theMan.html">Hey</a>
Hey
</ul>
</div>
</div>
</ul>
</body>
</html>
You have a fair amount of invalid HTML in there. Divs cannot be children of ul. You might want to validate your HTML first.
Therefore with a little re-structuring of the HTML to make it valid.
ul {
text-align: center;
list-style-type: none;
margin: 0;
padding: 0;
padding-bottom: 5px;
background-color: black;
display: block;
}
li a {
text-decoration: none;
display: block;
padding: 10px;
color: white;
}
li a:hover {
background-color: red;
}
li {
display: inline-block;
}
/* Building about dropdown and the dropdown content */
.container {
//width: 15em;
}
.dropdown {
position: relative;
}
.dropdown-content {
text-align: center;
position: absolute;
top: 100%;
left: 0;
display: none;
background-color: black;
color: white;
}
.dropdown:hover .dropdown-content {
display: block;
}
<ul>
<li>Home
</li>
<li>News
</li>
<li class="dropdown">About
<ul class="dropdown-content">
<li><a style="text-decoration = none;" href="#theMan.html">Hey</a>
</li>
<li>Hey
</li>
</ul>
</li>
</ul>
Check My Fiddle
ul {
text-align: center;
list-style-type: none;
margin: 0;
padding-bottom: 5px;
background-color: black;
display: block;
}
li a {
text-decoration: none;
padding: 14px 20px;
color: white;
}
li a:hover {
background-color: red;
}
li {
display: inline;
}
/* Building about dropdown and the dropdown content */
.container {
width: 15em;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
text-align: center;
position: absolute;
display: none;
background-color: black;
color: white;
}
/*added lines*/
.dropdown-content a{
text-decoration:none;
}
.dropdown-content a:hover{
color:red;/*font-color will be red*/
}
/*added lines ends here*/
.dropdown:hover .dropdown-content {
display: block;
}
<body>
<ul>
<li>Home</li>
<li>News</li>
<div class="dropdown">
<li>About</li>
<div class="dropdown-content"><ul>
Hey
Hey
</ul>
</div>
</div>
</ul>
</body>
1.) You have to put your submenu entries into li tags (they are in a ul tag!)
2.) The .dropdown-content selector/rule has to be changed to .dropdown-content ul
3.) quite some other stuff, but that wasn't part of the question.
ul {
text-align: center;
list-style-type: none;
margin: 0;
padding-bottom: 5px;
background-color: black;
display: block;
}
li a {
text-decoration: none;
padding: 14px 20px;
color: white;
}
li a:hover {
background-color: red;
}
li {
display: inline;
}
/* Building about dropdown and the dropdown content */
.container {
width: 15em;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content ul {
text-align: center;
position: absolute;
display: none;
background-color: black;
color: white;
padding: 0;
}
.dropdown:hover .dropdown-content ul {
display: block;
}
<ul>
<li>Home
</li>
<li>News
</li>
<div class="dropdown">
<li>About
</li>
<div class="dropdown-content">
<ul>
<li><a style="text-decoration = none;" href="#theMan.html">Hey</a>
</li>
<li>Hey
</li>
</ul>
</div>
</div>
</ul>

How to add second drop down menu to the first one?

i make a drop down menu with css, but i want to ask you, how can i add secondary drop down to the first? If it can't be made with this code, how can i make it? I try to use droppy, but the code bugged i mean the style..
I use this HTML:
<ul id="menu">
<!-- put class="selected" in the li tag for the selected page - to highlight which page you're on -->
<li class="selected">Index</li>
<div class="dropdown">
<li>Drop Down</li>
<div class="dropdown-content">
Link 1
Link 2
Link 3 --> Here i want to add another drop down menu
Link 4
</div>
</div></ul>
And this CSS:
ul#menu
{ float: right;
margin: 0;}
ul#menu li
{ float: left;
list-style: none;
margin: 2px 2px 0 0;
background: #5A5A5A url(tab.png) no-repeat 0 0;
border-top-right-radius: 1.5em;
border-top-left-radius: 1.5em;
overflow:hidden;
max-height: 27px;}
ul#menu li a
{ font: normal 100% 'trebuchet ms', sans-serif;
display: block;
float: left;
height: 20px;
padding: 6px 35px 5px 28px;
text-align: center;
color: #FFF;
text-decoration: none;
background: #5A5A5A url(tab.png) no-repeat 100% 0;}
ul#menu li.selected a
{ height: 20px;
padding: 6px 35px 5px 28px;}
ul#menu li.selected
{ margin: 2px 2px 0 0;
background: #00C6F0 url(tab_selected.png) no-repeat 0 0;
}
ul#menu li.selected a, ul#menu li.selected a:hover
{ background: #00C6F0 url(tab_selected.png) no-repeat 100% 0;
color: #FFF;}
ul#menu li a:hover
{ color: #E4EC04;}
/* The container <div> - needed to position the dropdown content */
.dropdown {
float:left;
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
margin-top: 30px;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
border-radius: 15px;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
border-radius: 15px;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
I should say that I kept slogging for more than an hour to get this up. As I have just learned HTML and CSS. But enjoyed doing it as it made me learn something new. Thanks.
Here is what I have so far:
CSS:
#menu, #first, #second, #third {
list-style-type: none;
border: 1px solid black;
}
#menu {
text-align: center;
padding-right: 10px;
padding-left: 10px;
width: 70px;
margin: 25px;
}
#first, #second, #third {
position: absolute;
background-color: #f9f9f9;
width: 50px;
display:none;
padding-left: 0;
width: 90px;
margin-left: 25px;
margin-right: 25px;
}
a {
text-decoration: none;
color: black;
}
#menu:hover #first {
display: block;
}
#first:hover #second {
display: block;
}
.hover3:hover #third {
display: block;
}
And here is the HTML:
<ul id="menu">
<!-- put class="selected" in the li tag for the selected page - to highlight which page you're on -->
<li class="hover">Index
<ul id="first">
<li class="hover2">Drop Down
<ul id="second">
<li> Link 1 </li>
<li>Link 2</li>
<li class="hover3">Link 3
<ul id="third">
<li>Link 4</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>