I have created a button (lets call it Menu button) that has 3 lines on it to symbolise a menu. When the user hovers over it displays a list. Up to here the code is doing what I want. It was showing the two buttons however when I give each button a nested list the display goes all funny. Here is my fiddle so far
What I want is when the menu button is hovered over it displays two further buttons (or I guess can just be list items), one button called Region and one called Export. When either of these are hovered over I would like them to display a list to the side of themselves.
HTML
<div class="dropdown">
<button class="dropbtn">
<div class="navbar">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
</button>
<div class="dropdown-content">
<ul>
<li>
<button class="dropbtn" value="Region">
<div class="dropdown-content">
<ul>
<li>Japan</li>
<li>South America</li>
<li>Europe</li>
</ul>
</div>
</li>
<li>
<button class="dropbtn" value="Export">
<div class="dropdown-content">
<ul>
<li>Excel</li>
<li>CSV</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
CSS
* {
margin: 0px;
padding: 0px;
}
body {
background-color: lightblue;
}
.navbar {
width: 50%;
display: block;
margin: 50px auto;
padding: 8px 10px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.navbar div {
height: 5px !important;
background: #fff;
margin: 7px 0px 7px 0px;
border-radius: 25px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.two {
width: 35px;
}
.three {
width: 50px;
}
.navbar:hover div {
width: 60px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: #9FACEC;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropbtnLi {
background-color: #9FACEC;
color: white;
font-size: 16px;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content li {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content li:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #4C66E9;}
On hovering you need to display them separately, i.e. when hovering
the main button, display only the sub-buttons. And when you hover the
sub-buttons then you can display the list.
* {
margin: 0px;
padding: 0px;
}
body {
background-color: lightblue;
}
/* vertical threline nav bar */
.navbar {
width: 50%;
display: block;
margin: 50px auto;
padding: 8px 10px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.navbar div {
height: 5px !important;
background: #fff;
margin: 7px 0px 7px 0px;
border-radius: 25px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.two {
width: 35px;
}
.three {
width: 50px;
}
.navbar:hover div {
width: 60px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: #9FACEC;
color: white;
padding: 16px;
font-size: 16px;
border: none;
width: 100%;
}
.dropbtnLi {
background-color: #9FACEC;
color: white;
font-size: 16px;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content li {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
position: relative;
}
/* Change color of dropdown links on hover */
.dropdown-content li:hover {background-color: #ddd;}
/* 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: #4C66E9;}
.dropdown-content-list {
display: none;
}
.dropdown-content-list:hover {
display: block !important;
}
.dropdown-content-li:hover .dropdown-content-list {
display: block;
position: absolute;
left: 100%;
top: 0;
background: #efefef;
}
<div class="dropdown">
<button class="dropbtn">
<div class="navbar">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
</button>
<div class="dropdown-content">
<ul>
<li class="dropdown-content-li">
<button class="dropbtn" value="Region">Country</button>
<div class="dropdown-content-list">
<ul>
<li>Japan</li>
<li>South America</li>
<li>Europe</li>
</ul>
</div>
</li>
<li class="dropdown-content-li">
<button class="dropbtn">Export</button>
<div class="dropdown-content-list">
<ul>
<li>Excel</li>
<li>CSV</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
Here is working code.
* {
margin: 0px;
padding: 0px;
}
body {
background-color: lightblue;
}
/* vertical threline nav bar */
.navbar {
width: 50%;
display: block;
margin: 50px auto;
padding: 8px 10px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.navbar div {
height: 5px !important;
background: #fff;
margin: 7px 0px 7px 0px;
border-radius: 25px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.two {
width: 35px;
}
.three {
width: 50px;
}
.navbar:hover div {
width: 60px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: #9FACEC;
color: white;
padding: 16px;
font-size: 16px;
border: none;
}
.dropbtnLi {
background-color: #9FACEC;
color: white;
font-size: 16px;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content li {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content li:hover {background-color: #ddd;}
/* 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: #4C66E9;}
<div class="dropdown">
<button class="dropbtn">
<div class="navbar">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
</button>
<div class="dropdown-content">
<ul>
<li>
<button class="dropbtn" value="Region">
<div class="dropdown-content">
<ul>
<li>Japan</li>
<li>South America</li>
<li>Europe</li>
</ul>
</div>
</li>
<li>
<button class="dropbtn">
<div class="dropdown-content">
<ul>
<li>Excel</li>
<li>CSV</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
Or you can set direct child for hovering on parent li. like .dropdown:hover > .dropdown-content {display: block;}
Related
I have a menu button and everything is working nicely. However the button appears quite tall on my page. Even in my fiddle example I can't seem to change the height no matter what I change, why?
I can't see anywhere a height specified either?
* {
margin: 0px;
padding: 0px;
}
body {
background-color: lightblue;
}
.navbar {
width: 50%;
display: block;
margin: 50px auto;
padding: 8px 10px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.navbar div {
height: 5px !important;
background: #fff;
margin: 7px 0px 7px 0px;
border-radius: 25px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.two {
width: 35px;
}
.three {
width: 50px;
}
.navbar:hover div {
width: 60px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: #9FACEC;
color: white;
padding: 16px;
font-size: 16px;
border: none;
width: 100%;
}
.dropbtnSub {
background-color: #f1f1f1;
color: black;
padding: 16px;
font-size: 16px;
border: none;
width: 100%;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content li {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
position: relative;
}
/* Change color of dropdown links on hover */
.dropdown-content li:hover {background-color: #ddd;}
.dropbtnSub-content:hover {background-color: #4C66E9;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #4C66E9;}
.dropdown-content-list {
display: none;
}
.dropdown-content-list:hover {
display: block !important;
}
.dropdown-content-li:hover .dropdown-content-list {
display: block;
position: absolute;
left: 100%;
top: 0;
background: #efefef;
}
<div class="dropdown">
<button class="dropbtn">
<div class="navbar">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
</button>
<div class="dropdown-content">
<ul>
<li class="dropdown-content-li">
<button class="dropbtnSub" value="Region">Country</button>
<div class="dropdown-content-list">
<ul>
<li>Japan</li>
<li>South America</li>
<li>Europe</li>
</ul>
</div>
</li>
<li class="dropdown-content-li">
<button class="dropbtnSub">Export</button>
<div class="dropdown-content-list">
<ul>
<li>Excel</li>
<li>CSV</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
Try changing margin applied in your custom class navbar from 50px to 0px
* {
margin: 0px;
padding: 0px;
}
body {
background-color: lightblue;
}
.navbar {
width: 50%;
display: block;
margin: 0px;
padding: 8px 10px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.navbar div {
height: 5px !important;
background: #fff;
margin: 7px 0px 7px 0px;
border-radius: 25px;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.two {
width: 35px;
}
.three {
width: 50px;
}
.navbar:hover div {
width: 60px;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropbtn {
background-color: #9FACEC;
color: white;
padding: 16px;
font-size: 16px;
border: none;
width: 100%;
}
.dropbtnSub {
background-color: #f1f1f1;
color: black;
padding: 16px;
font-size: 16px;
border: none;
width: 100%;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f1f1f1;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content li {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
position: relative;
}
/* Change color of dropdown links on hover */
.dropdown-content li:hover {background-color: #ddd;}
.dropbtnSub-content:hover {background-color: #4C66E9;}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #4C66E9;}
.dropdown-content-list {
display: none;
}
.dropdown-content-list:hover {
display: block !important;
}
.dropdown-content-li:hover .dropdown-content-list {
display: block;
position: absolute;
left: 100%;
top: 0;
background: #efefef;
}
<div class="dropdown">
<button class="dropbtn">
<div class="navbar">
<div class="one"></div>
<div class="two"></div>
<div class="three"></div>
</div>
</button>
<div class="dropdown-content">
<ul>
<li class="dropdown-content-li">
<button class="dropbtnSub" value="Region">Country</button>
<div class="dropdown-content-list">
<ul>
<li>Japan</li>
<li>South America</li>
<li>Europe</li>
</ul>
</div>
</li>
<li class="dropdown-content-li">
<button class="dropbtnSub">Export</button>
<div class="dropdown-content-list">
<ul>
<li>Excel</li>
<li>CSV</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
Put margin: 0 auto on .navbar.
change from .navbar {margin:50px auto;} to .navbar{margin:0px auto;} or you can also use -5px auto for smaller size of button
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">
The hover div of items should stay stable but it doesn't, when I move cursor from hover a tag it goes away
#ul1 {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
width: 100px;
}
li {
width: 100px;
display: block;
}
li a,
.dropbtn {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: orange;
}
li.dropdown {
display: block;
}
li.dropdown2 {
display: block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: green;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.dropdown-content2 {
display: none;
position: absolute;
background-color: green;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
}
.dropdown-content a {
color: white;
padding: 20px 20px;
text-decoration: none;
display: block;
text-align: center;
}
.dropdown-content2 a {
position: relative;
top: 100px;
left: 500px;
color: white;
background-color: red;
padding: 20px 20px;
text-decoration: none;
display: block;
text-align: center;
}
.dropdown-content a:hover {
background-color: pink;
}
dropdown-content2 a:hover {
background-color: pink;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown2:hover .dropdown-content2 {
display: block;
}
<ul id="ul1">
<li> Home </li>
<li> Services </li>
<li class="dropdown">
Products
<div class="dropdown-content">
<ul id="ul2">
<li class="dropdown2"> Mobiles
<div class="dropdown-content2">
Mobile1
Mobile2
Mobile3
Mobile4
Mobile5
</div>
</li>
<li> Televisions </li>
<li> Microwave </li>
<li> Clothing </li>
<li> Footware </li>
</ul>
</div>
</li>
</ul>
I have tried many things to deal with this like scaling padding to max or increasing width and height but nothing works.
The div goes away as soon as I move my cursor for hovered item
I removed position:absolute from the dropdown <a> tags and fixed the positioning of each dropdown level. This resolves the positioning of submenus in relation to the parent menu.
The hover mechanism works well with the arrangement of the menus. When you hover out, the menus disappear, which is standard behavior for drop-down menus. If you wish to leave the menu visible on hover out, you will need to define a javascript function that controls menu visibility, for instance, hiding when clicking on a menu item.
#ul1 {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: black;
width: 160px;
}
li {
width: 160px;
display: block;
}
li a,
.dropbtn {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: orange;
}
li.dropdown {
display: block;
}
li.dropdown2 {
display: block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: green;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
left:166px;
margin-top:-46px;
}
.dropdown-content2 {
display: none;
position: absolute;
background-color: green;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
left:160px;
margin-top:-46px;
}
.dropdown-content a {
color: white;
/*padding: 20px 20px;*/
text-decoration: none;
display: block;
text-align: center;
}
.dropdown-content2 a {
color: white;
background-color: red;
/*padding: 20px 20px;*/
text-decoration: none;
display: block;
text-align: center;
}
.dropdown-content a:hover {
background-color: pink;
}
dropdown-content2 a:hover {
background-color: pink;
}
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown2:hover .dropdown-content2 {
display: block;
}
#ul2 {padding:0px;}
<ul id="ul1">
<li> Home </li>
<li> Services </li>
<li class="dropdown">
Products
<div class="dropdown-content">
<ul id="ul2">
<li class="dropdown2" style="position:relative;"> Mobiles
<div class="dropdown-content2">
Mobile1
Mobile2
Mobile3
Mobile4
Mobile5
</div>
</li>
<li> Televisions </li>
<li> Microwave </li>
<li> Clothing </li>
<li> Footware </li>
</ul>
</div>
</li>
</ul>
I'm having an issue with the CSS of the navigation bar.This is what happens when I hover over .dropbtn.
Here's my HTML code for the drop down navigation bar.
<div class="nav-wrapper">
<ul id="nav">
<img id="logo" src="Images/dramay.jpg">
<li class="dropdown">
Movies & TV ⏷
<div class="dropdown-content">
<b style="font-size: 15px">MOVIES</b>
In Theaters
Coming Soon
Categories
Most Popular
<b style="font-size: 15px" > TV </b>
<a href="#" >Timings</a>
Latest shows
Top rated
</div>
</li>
<li class="dropdown">
Celebs & photos ⏷
<div class="dropdown-content">
<b style="font-size: 15px">Celebs</b>
Born today
Most popular
<b style="font-size: 15px">Photos</b>
latest stills
Latest posters
</div>
</li>
<li class="dropdown">
News ⏷
<div class="dropdown-content">
<b style="font-size: 15px">News</b>
Top news
Movies news
TV news
</div>
</li>
<li class="search" style="float:right;"><a>
<input type="text" name="firstname" placeholder="SEARCH">
</a>
</li>
<li class="dropdown" id="signIN">
Sign In
</li>
<li class="dropdown" id="signUP">
Sign Up
</li>
</ul>
</div>
And here's the CSS.
ul#nav {
list-style-type: none;
margin: 0;
padding: 0;
position: inherit;
width: 100%;
overflow: hidden;
background: #332;
}
.nav-wrapper
{
position: fixed;
width: 100%;
}
li {
float: left;
}
li a, .dropbtn {
display: inline-block;
color: lightgrey;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color:#00b300;
}
li a:hover, .search:hover {
background-color:black;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
color:black;
position: relative;
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;
font-size: 15px;
z-index: 1;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
I have tried overflow:hidden on ul#nav and .nav-wrapper but none of it works.
(Apologies in advance for my bad english)
add following css
ul#nav {
overflow: visible;
}
ul#nav li {
position: relative;
}
.dropdown-content {
position: absolute;
left: 0px;
top: 100%;
}
Make 2 change in your css :-
1) Remove overflow: hidden; in ul#nav class
ul#nav {
list-style-type: none;
margin: 0;
padding: 0;
position: inherit;
width: 100%;
/*overflow: hidden;*/
background: #332;
}
2) Change position in .dropdown-content
.dropdown-content {
background-color: #f9f9f9;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
color: black;
display: none;
min-width: 160px;
position: absolute;
z-index: 1;
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.templatemo_menu {
position: relative;
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);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.templatemo_menu:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
#templatemo_menu {
float: left;
height: 37px;
margin-top: 12px;
overflow:hidden;
}
<div id="templatemo_menu">
<ul>
<li>Home</li>
<li ><a href="Aboutus.html" class="dropbtn" >Coindia</a>
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
<li>Services</li>
<li>Facility</li>
<li>Photo Gallery</li>
<li>Careers</li>
</ul>
</div> <!-- end of templatemo_menu -->
I want to create submenu in HTML. Here i have created menu and submenu but it is not appearing properly. Please help me with this.i want the sub-menu open to down side when cursor is placed on it Here is the css and html relating to it
A few small edits will cause the drop down to work, there appears to be some other work left to do.
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.templatemo_menu {
position: relative;
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);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
.templatemo_menu .dropdown-content {
display: none;
}
.templatemo_menu:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
#templatemo_menu {
float: left;
height: 37px;
margin-top: 12px;
overflow:hidden;
}
<div>
<ul>
<li>Home</li>
<li class="templatemo_menu"><a href="Aboutus.html" class="dropbtn" >Coindia</a>
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
<li>Services</li>
<li>Facility</li>
<li>Photo Gallery</li>
<li>Careers</li>
</ul>
</div> <!-- end of templatemo_menu -->
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
#templatemo_menu {
position: relative;
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);
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #f1f1f1}
#templatemo_menu:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
#templatemo_menu {
float: left;
// height: 37px;
margin-top: 12px;
// overflow:hidden;
}
<div id="templatemo_menu">
<ul>
<li>Home</li>
<li ><a href="Aboutus.html" class="dropbtn" >Coindia</a>
<button class="dropbtn">Dropdown</button>
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
<li>Services</li>
<li>Facility</li>
<li>Photo Gallery</li>
<li>Careers</li>
</ul>
</div> <!-- end of templatemo_menu -->
<div id="templatemo_menu"> You have given id templatemo_menu and in you css you have given .templatemo_menu.You have to use #templatemo_menu for id. Also change the style of #templatemo_menu
#templatemo_menu {
float: left;
// height: 37px;
margin-top: 12px;
//overflow:hidden;
}