.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;
}
Related
I'm creating a multi-level drop-down list and I got everything made in html but it seems when I go into CSS all the levels are connected to the same .dropdown. Does anyone know how I can link my different drop-down lists to their own CSS .dropdown instead of it all being linked to the same one? Any help will be greatly appreciated, thanks!
body {
margin:0;
padding: 0;
font-family: "Open+Sans", sans-serif;
}
.navbar {
border-bottom: 2px solid #0C133C;
}
#nav {
background-color: #fff;
color: white;
width: 100%;
}
.nav {
float: right;
text-align: left;
margin: 0;
}
.nav > li {
display:Inline-block;
padding: 20px 50px 10px 9px;
}
.nav > li a {
text-decoration: none;
color: #0C133C;
font-size: 18px;
border-bottom: 3px solid transparent;
}
.clearer {
clear:both;
}
.subnav class{
margin: 0;
position:relative;
}
.subnav > div a {
text-decoration: none;
color: #0C133C;
font-size: 18px;
padding: 20px 30px 10px 9px;
}
.logo {
margin-top: 1rem;
}
.subnav {
display: flex;
justify-content: space-between;
align-items: center;
margin-right: 1rem;
}
.split {
height: 70%;
width: 50%;
position: fixed;
z-index: 1;
top: -50;
overflow-x: hidden;
padding-top: 20px;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.left {
left: 0;
background-color: #282C41;
color: white;
margin-top: .5rem;
font-size: 15px;
}
.right {
right: 0;
background-color: #CDCDCD;
margin-top: .5rem;
font-size: 18px;
}
.dropbtn {
background-color: #FFFFFF;
color: black;
padding: 10px 10px ;
font-size: 16px;
border: none;
border-radius: 10px;
}
.dropdown {
position: relative;
display: inline-block;
left: 175px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #FFF;
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;
}
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #868686;}
-------Dropdown 2------
.dropbtn 2 {
background-color: #FFFFFF;
color: black;
padding: 10px 10px ;
font-size: 16px;
border: none;
border-radius: 10px;
}
.dropdown 2 {
position: relative;
display: inline-block;
left: 175px;
}
.dropdown-content 2 {
display: none;
position: absolute;
background-color: #FFF;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a 2 {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #868686;}
------Dropdown 3 ----
.dropbtn 3 {
background-color: #FFFFFF;
color: black;
padding: 10px 10px ;
font-size: 16px;
border: none;
border-radius: 10px;
}
.dropdown 3 {
position: relative;
display: inline-block;
left: 175px;
}
.dropdown-content 3 {
display: none;
position: absolute;
background-color: #FFF;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a 3 {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #868686;}
------Dropdown 4-----
.dropbtn 4 {
background-color: #FFFFFF;
color: black;
padding: 10px 10px ;
font-size: 16px;
border: none;
border-radius: 10px;
}
.dropdown 4 {
position: relative;
display: inline-block;
left: 175px;
}
.dropdown-content 4 {
display: none;
position: absolute;
background-color: #FFF;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a 4{
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {background-color: #ddd;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover .dropbtn {background-color: #868686;}
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Navbar</title>
<link rel="stylesheet" href="styles.css"
</head>
<body>
<div class="navbar">
<ul class="nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Sign In</a>
</li>
</ul>
<div class="clearer"></div>
</div>
<subnav class="subnav subnav-light bg-light">
<img src="universallogo.jpg" class="logo"/>
<div class="container-fluid">
<a class="subnav=brand" href="#">
<a class="nav-link active" aria-current="page" href="#">Bonds</a>
</a>
<a class="nav-link active" aria-current="page" href="#">Report a Claim</a>
<a class="nav-link active" aria-current="page" href="#">About Us</a>
<a class="nav-link active" aria-current="page" href="#">Search</a>
</div>
</subnav>
<div class="split left">
<div class="centered">
<h1>GET YOUR LICENSE & PERMIT BONDS FAST & EASY</h1>
<p>We provide our Customers with a fast, easy, and secure way to get bonded. Get your Free Quote in minutes.
</p>
</div>
</div>
<div class="split right">
<div class="dropdown">
<button class="dropbtn">Select Your State</button>
<div class="dropdown-content">
California
Illinois
Michigan
Ohio
</div>
<div class="dropdown2">
<button class="dropbtn">Who is requring the bond</button>
<div class="dropdown-content">
Who is requring the bond
</div>
<div class="dropdown3">
<button class="dropbtn">What jurisdiction is requring the bond</button>
<div class="dropdown-content">
What jurisdiction is requring the bond
</div>
<div class="dropdown3">
<button class="dropbtn">Select Your Bond</button>
<div class="dropdown-content">
Select Your Bond
</div>
</div>
</body>
</html>
Multilevel Dropdown Menu
ul {
list-style: none;
padding: 0;
margin: 0;
background: #1bc2a2;
}
ul li {
display: block;
position: relative;
float: left;
background: #1bc2a2;
}
li ul {
display: none;
}
ul li a {
display: block;
padding: 1em;
text-decoration: none;
white-space: nowrap;
color: #fff;
}
ul li a:hover {
background: #2c3e50;
}
li:hover>ul {
display: block;
position: absolute;
}
li:hover li {
float: none;
}
li:hover a {
background: #1bc2a2;
}
li:hover li a:hover {
background: #2c3e50;
}
.main-navigation li ul li {
border-top: 0;
}
ul ul ul {
left: 100%;
top: 0;
}
ul:before,
ul:after {
content: " ";
/* 1 */
display: table;
/* 2 */
}
ul:after {
clear: both;
}
<ul class="main-navigation">
<li>Front End Design
<ul>
<li>HTML</li>
<li>CSS
<ul>
<li>Resets</li>
<li>Grids</li>
<li>Frameworks</li>
</ul>
</li>
<li>JavaScript
<ul>
<li>Ajax</li>
<li>jQuery</li>
</ul>
</li>
</ul>
</li>
</ul>
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;}
I have two pages of code. I want the first page's dropdown menu to look like the second page's dropdown menu. The second page is some code I copied and pasted from W3 Schools.
The problem is on the first page the drop down menu's width is the same as the navigation bar. I want to have a smaller width for the navigation bar and I can't figure out how why it is the same width of navigation bar.
First Page
ul {
margin: 0;
padding: 0;
background-color: green;
overflow: hidden;
list-style-type: none;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
padding: 50px 100px;
text-decoration: none;
color: white;
}
li a:hover {
color: white;
background-color: #333;
}
.dropdown {
display: inline-block;
}
.dropcont {
display: none;
position: absolute;
background-color: #333 min-width:200px;
z-index: 1;
}
.dropcont a {
color: white;
padding: 12px 16px;
display: block;
text-align: left;
}
.dropdown:hover .dropcont {
display: block;
}
<ul>
<li> Home</li>
<li> Your Home</li>
<li>Home Sales</li>
<li class="dropdown">
Home profile
<div class="dropcont">
Home2
Home3
Home4
</div>
</li>
</ul>
Second Page
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
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;
}
<ul>
<li>Home</li>
<li>News</li>
<li class="dropdown">
Dropdown
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
</ul>
Here is the updated css :
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color:green;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color:#333;
}
li.dropdown {
display: inline-block;
}
.dropcont {
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;
}
.dropcont a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropcont a:hover {
background-color: #f1f1f1
}
.dropdown:hover .dropcont {
display: block;
}
<ul>
<li> Home</li>
<li> Your Home</li>
<li>Home Sales</li>
<li class="dropdown">
Home profile
<div class="dropcont">
Home2
Home3
Home4
</div>
</li>
</ul>
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
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>
<style>
ulf {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
bottom: 0%;
width: 100%;
}
lif {
float: left;
border-right: 1px solid #bbb;
}
lif a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
lif a:hover, .dropup:hover .dropbtn {
background-color: red;
}
lif.dropup {
display: inline-block;
}
.dropup-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;
}
.dropup-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropup-content a:hover {
background-color: #f1f1f1
}
.dropup:hover .dropup-content {
display: block;
}
</style>
</head>
<body>
<ul>
</li><li class="dropdown">
Sales
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Search
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Transfers
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Returns
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
</ul>
<ulf>
<lif class="dropup">
Order
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Reports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Exports/Imports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Settings
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
</ulf>
</body>
</html>
The top navigation is working properly. I mean the drop down is functional,but the bottom navigation isn't working. I want to do something like drop up. Can someone please check the code and give me some instruction on what i have to do?
You just need to remove position: absolute; from .dropup-content, and replace it with this CSS:
position: fixed;
bottom: 47px;
And and Bob's your uncle!
ulf {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
bottom: 0%;
width: 100%;
}
lif {
float: left;
border-right: 1px solid #bbb;
}
lif a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
lif a:hover, .dropup:hover .dropbtn {
background-color: red;
}
lif.dropup {
display: inline-block;
}
.dropup-content {
display: none;
position: fixed;
bottom: 47px;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropup-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropup-content a:hover {
background-color: #f1f1f1
}
.dropup:hover .dropup-content {
display: block;
}
<!DOCTYPE html>
<html>
<head>
<style>
</style>
<style>
</style>
</head>
<body>
<ulf>
<lif class="dropup">
Order
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Reports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Exports/Imports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Settings
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
</ulf>
</body>
</html>
CodePen example:
Two things:
1.) Add bottom: 0 to .dropup-content to align the submenus to the bottom of their container, not the top.
2.) Add overflow-visible to ulf
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: red;
}
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;
}
ulf {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
bottom: 0%;
width: 100%;
overflow: visible;
}
lif {
float: left;
border-right: 1px solid #bbb;
}
lif a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
lif a:hover,
.dropup:hover .dropbtn {
background-color: red;
}
lif.dropup {
display: inline-block;
}
.dropup-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;
bottom: 0;
}
.dropup-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropup-content a:hover {
background-color: #f1f1f1
}
.dropup:hover .dropup-content {
display: block;
}
<!DOCTYPE html>
<html>
<body>
<ul>
</li>
<li class="dropdown">
Sales
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Search
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Transfers
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Returns
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
</ul>
<ulf>
<lif class="dropup">
Order
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Reports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Exports/Imports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Settings
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
</ulf>
</body>
</html>
Remove overflow hidden from ulf, add bottom: 46px to .dropup-content to get it above the bottom nav.
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
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>
<style>
ulf {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #333;
position: fixed;
bottom: 0%;
width: 100%;
}
lif {
float: left;
border-right: 1px solid #bbb;
}
lif a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
lif a:hover, .dropup:hover .dropbtn {
background-color: red;
}
lif.dropup {
display: inline-block;
}
.dropup-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;
bottom:46px;
}
.dropup-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropup-content a:hover {
background-color: #f1f1f1
}
.dropup:hover .dropup-content {
display: block;
}
</style>
</head>
<body>
<ul>
<li class="dropdown">
Sales
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Search
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Transfers
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
<li class="dropdown">
Returns
<div class="dropdown-content">
Link 1
Link 2
Link 3
</div>
</li>
</ul>
<ulf>
<lif class="dropup">
Order
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Reports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Exports/Imports
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
<lif class="dropup">
Settings
<div class="dropup-content">
Link 1
Link 2
Link 3
</div>
</lif>
</ulf>
</body>
</html>
I am trying to create a drop-down menu that should have 2 levels of dropdown. I want the a menu item (Product), when I hover over its sub-menu(Our Brands) it should come with an arrow and drop-down to side.
Demo :- https://jsfiddle.net/nnefhpxf/
HTML
<div id="navbar-collapse-grid" class="navbar-collapse collapse">
<ul class="nav navbar-nav" id = "drop-nav">
<li><a class="active" href="index.html">Home</a></li>
<li class="dropdown">
Our Company
<div class="dropdown-content">
Company Overview
Management
Manufacturing
Business
</div>
</li>
<li class="dropdown">
Product
<div class="dropdown-content">
Our Brand
<ul>
<li>Intes-o</li>
<li>Frig-M</li>
<li>Rahat</li>
<li>Zesund</li>
<li>Bioti 1gm I.V</li>
<li>Vomiss I.V</li>
</ul>
New Brand Releases
</div>
</li>
<li>Mission</li>
<li>Vision</li>
<li>Contact Us</li>
</ul>
</div>
css
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: gray;
font-size: 17px;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: #75c5cf;
}
li.dropdown {
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgb3a(0, 0, 0, 0.2);
}
.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;
}
Try this. The hover arrow on the brand item I have uploaded from the local. Please check the below code.
/* css */
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: gray;
font-size: 17px;
}
li {
float: left;
}
li a,
.dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
li a:hover,
.dropdown:hover .dropbtn {
background-color: #75c5cf;
}
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);
}
.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;
}
.sub-mnu {
position: absolute;
left: 174px;
top: 0px;
}
.dropdown-content ul {
display: none;
}
.dropdown-content:hover ul {
display: block;
}
.brnd {
background-image: url(https://www.dropbox.com/s/fhjnwgbokn8i8eo/arrow.png);
background-position: right;
background-repeat: no-repeat;
}
<div id="navbar-collapse-grid" class="navbar-collapse collapse">
<ul class="nav navbar-nav" id="drop-nav">
<li><a class="active" href="index.html">Home</a>
</li>
<li class="dropdown">
Our Company
<div class="dropdown-content">
Company Overview
Management
Manufacturing
Business
</div>
</li>
<li class="dropdown">
Product
<div class="dropdown-content">
Our Brand
<ul class="sub-mnu">
<li>Intes-o
</li>
<li>Frig-M
</li>
<li>Rahat
</li>
<li>Zesund
</li>
<li>Bioti 1gm I.V
</li>
<li>Vomiss I.V
</li>
Zesund
</ul>
New Brand Releases
</div>
</li>
<li>Mission
</li>
<li>Vision
</li>
<li>Contact Us
</li>
</ul>
</div>