Hey i have quite a bit of a design to my dropdown menu and im having trouble adding a submenu to lets say to the first element on the dropdown-cotent div.
I simply want the sub menu to start where the hover of the submeneu is defined and to the right and drop down the same way as my current sub menu does it.
Here is my html:
<nav>
<div class="main-nav">
<ul class="left">
<li class="dropdown">Home
<div class="dropdown-content">
Third
Third Link
Third Link 3
</div>
</li>
<li>Gods</li>
<li>Goddesses</li>
</ul>
<div class="play-now"></div>
<ul class="right">
<li>Heroes</li>
<li>Myths</li>
<li>Beasts</li>
</ul>
</div>
</nav>
And here is the css to it all:
nav {
padding-left: 5px
}
nav .main-nav {
height: 80px;
width: 100%;
margin-top: 64px;
background: url(../images/navHeader.png) no-repeat top;
position: relative
}
nav .main-nav ul {
width: 360px;
height: 80px;
margin-top: 2px;
padding: 0;
list-style-type: none
}
nav .main-nav ul a,
nav .main-nav ul li {
display: inline-block;
width: 105px;
line-height: 80px;
height: 80px
}
nav .main-nav .dropdown-content a {
height: auto;
line-height: initial;
padding: 3px 0;
}
nav .main-nav ul a {
text-align: center;
font-weight: 550;
font-size: 12px;
color: #84827d;
text-shadow: 1px 1px 1px 1px #000;
text-transform: uppercase;
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out
}
nav .main-nav ul a:hover {
text-decoration: none;
color: #7289da
}
nav .main-nav li .dropdown {
}
nav .main-nav .dropdown-content {
position: absolute;
display: none;
float: left;
z-index: 10;
-webkit-box-shadow: 0 3px 5px 0 #999;
-moz-box-shadow: 0 3px 5px 0 #999;
box-shadow: 0 3px 5px 0 #999;
border: 1px solid #CCC;
background: #3A4FC5;
color: #656161;
opacity: .8;
min-width: 30px;
top: 60px;
}
nav .main-nav .dropdown-content a {
color: black;
text-decoration: none;
display: block;
text-align: center;
}
nav .main-nav .dropdown-content a:hover {
background-color: #3A4FC5
}
nav .main-nav .dropdown:hover .dropdown-content {
display: inline-block;
}
nav .main-nav ul.left {
float: left;
margin-left: 5px;
}
nav .main-nav ul.right {
float: right;
margin-left: 5px
}
Here is snippet,
nav {
padding-left: 5px
}
nav .main-nav {
height: 80px;
width: 100%;
margin-top: 64px;
background: url(../images/navHeader.png) no-repeat top;
position: relative
}
nav .main-nav ul {
width: 360px;
height: 80px;
margin-top: 2px;
padding: 0;
list-style-type: none
}
nav .main-nav ul a,
nav .main-nav ul li {
display: inline-block;
width: 105px;
line-height: 80px;
height: 80px
}
nav .main-nav .dropdown-content a {
height: auto;
line-height: initial;
padding: 3px 0;
}
nav .main-nav ul a {
text-align: center;
font-weight: 550;
font-size: 12px;
color: #84827d;
text-shadow: 1px 1px 1px 1px #000;
text-transform: uppercase;
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out
}
nav .main-nav ul a:hover {
text-decoration: none;
color: #7289da
}
nav .main-nav li .dropdown {
}
nav .main-nav .dropdown-content {
position: absolute;
display: none;
float: left;
z-index: 10;
-webkit-box-shadow: 0 3px 5px 0 #999;
-moz-box-shadow: 0 3px 5px 0 #999;
box-shadow: 0 3px 5px 0 #999;
border: 1px solid #CCC;
background: #3A4FC5;
color: #656161;
opacity: .8;
min-width: 30px;
top: 60px;
}
nav .main-nav .dropdown-content a {
color: black;
text-decoration: none;
display: block;
text-align: center;
}
nav .main-nav .dropdown-content a:hover {
background-color: #3A4FC5
}
nav .main-nav .dropdown:hover .dropdown-content {
display: inline-block;
}
nav .main-nav ul.left {
float: left;
margin-left: 5px;
}
nav .main-nav ul.right {
float: right;
margin-left: 5px
}
<nav>
<div class="main-nav">
<ul class="left">
<li class="dropdown">Home
<div class="dropdown-content">
Third
Third Link
Third Link 3
</div>
</li>
<li>Gods</li>
<li>Goddesses</li>
</ul>
<div class="play-now"></div>
<ul class="right">
<li>Heroes</li>
<li>Myths</li>
<li>Beasts</li>
</ul>
</div>
</nav>
$(document).ready(function(){
$('.dropdown-submenu a.test').on("click", function(e){
$(this).next('ul').toggle();
e.stopPropagation();
e.preventDefault();
});
});
<style>
.dropdown-submenu {
position: relative;
}
.dropdown-submenu .dropdown-menu {
top: 0;
left: 100%;
margin-top: -1px;
}
</style>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">Dropdown
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">HTML</a></li>
<li><a tabindex="-1" href="#">CSS</a></li>
<li class="dropdown-submenu">
<a class="test" tabindex="-1" href="#">New dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a tabindex="-1" href="#">2nd level dropdown</a></li>
<li><a tabindex="-1" href="#">2nd level dropdown</a></li>
<li class="dropdown-submenu">
<a class="test" href="#">Another dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>3rd level dropdown</li>
<li>3rd level dropdown</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</body>
</html>
Did you mean to say this?
nav {
padding-left: 5px
}
nav .main-nav {
height: 80px;
width: 100%;
margin-top: 64px;
background: url(../images/navHeader.png) no-repeat top;
position: relative
}
nav .main-nav > ul {
width: 360px;
height: 80px;
margin-top: 2px;
padding: 0;
list-style-type: none
}
nav .main-nav ul a,
nav .main-nav ul li {
display: inline-block;
width: 105px;
line-height: 80px;
height: 80px
}
nav .main-nav .dropdown-content a {
height: auto;
line-height: initial;
padding: 3px 0;
}
nav .main-nav ul a {
text-align: center;
font-weight: 550;
font-size: 12px;
color: #84827d;
text-shadow: 1px 1px 1px 1px #000;
text-transform: uppercase;
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out
}
nav .main-nav ul a:hover {
text-decoration: none;
color: #7289da
}
nav .main-nav li .dropdown {
}
nav .main-nav .dropdown-content {
position: absolute;
display: none;
float: left;
z-index: 10;
-webkit-box-shadow: 0 3px 5px 0 #999;
-moz-box-shadow: 0 3px 5px 0 #999;
box-shadow: 0 3px 5px 0 #999;
border: 1px solid #CCC;
background: #3A4FC5;
color: #656161;
opacity: .8;
min-width: 30px;
top: 60px;
}
nav .main-nav .dropdown-content a {
color: black;
text-decoration: none;
display: block;
text-align: center;
}
nav .main-nav .dropdown-content a:hover {
background-color: #3A4FC5
}
nav .main-nav .dropdown:hover .dropdown-content {
display: inline-block;
}
nav .main-nav ul.left {
float: left;
margin-left: 5px;
}
.dropdown-content ul {
padding: 0;
width: auto !important;
display: flex;
flex-direction: column;
}
.dropdown-content ul li {
height: auto !important;
position: relative;
}
.dropdown-content ul li:hover > .dropdown-content-second {
display: block;
}
.dropdown-content-second {
position: absolute;
display: none;
float: left;
z-index: 10;
-webkit-box-shadow: 0 3px 5px 0 #999;
-moz-box-shadow: 0 3px 5px 0 #999;
box-shadow: 0 3px 5px 0 #999;
border: 1px solid #CCC;
background: #3A4FC5;
color: #656161;
opacity: .8;
min-width: 30px;
top: 0;
left: 100%;
}
.dropdown-content-second ul li {
position: relative;
}
nav .main-nav ul.right {
float: right;
margin-left: 5px
}
<nav>
<div class="main-nav">
<ul class="left">
<li class="dropdown">Home
<div class="dropdown-content">
<ul>
<li>
Third
<div class="dropdown-content-second">
<ul>
<li>
Navi 1
</li>
<li>
Navi 2
</li>
<li>
Navi 3
<div class="dropdown-content-second">
<ul>
<li>
Navi 1
</li>
<li>
Navi 2
</li>
<li>
Navi 3
</li>
<li>
Navi 4
</li>
<li>
Navi 5
</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
<li>
Third Link
</li>
<li>
Third Link 3
</li>
</ul>
</div>
</li>
<li>Gods</li>
<li>Goddesses</li>
</ul>
<div class="play-now"></div>
<ul class="right">
<li>Heroes</li>
<li>Myths</li>
<li>Beasts</li>
</ul>
</div>
</nav>
Take a look on my menu
#import url(https://fonts.googleapis.com/css?family=Oxygen+Mono);
/* Starter CSS for Menu */
#cssmenu {
padding: 0;
margin: 0;
border: 0;
width: auto;
}
#cssmenu ul,
#cssmenu li {
list-style: none;
margin: 0;
padding: 0;
}
#cssmenu ul {
position: relative;
z-index: 597;
}
#cssmenu ul li {
float: left;
min-height: 1px;
vertical-align: middle;
}
#cssmenu ul li.hover,
#cssmenu ul li:hover {
position: relative;
z-index: 599;
cursor: default;
}
#cssmenu ul ul {
visibility: hidden;
position: absolute;
top: 100%;
left: 0;
z-index: 598;
width: 100%;
}
#cssmenu ul ul li {
float: none;
}
#cssmenu ul ul ul {
top: 0;
left: 190px;
width: 190px;
}
#cssmenu ul li:hover > ul {
visibility: visible;
}
#cssmenu ul ul {
bottom: 0;
left: 0;
}
#cssmenu ul ul {
margin-top: 0;
}
#cssmenu ul ul li {
font-weight: normal;
}
#cssmenu a {
display: block;
line-height: 1em;
text-decoration: none;
}
/* Custom CSS Styles */
#cssmenu {
background: #333;
border-bottom: 4px solid #9c9797;
font-family: 'Oxygen Mono', Tahoma, Arial, sans-serif;
font-size: 12px;
}
#cssmenu > ul {
*display: inline-block;
}
#cssmenu:after,
#cssmenu ul:after {
content: '';
display: block;
clear: both;
}
#cssmenu ul {
text-transform: uppercase;
}
#cssmenu ul ul {
border-top: 4px solid #9c9797;
text-transform: none;
min-width: 190px;
}
#cssmenu ul ul a {
background: #9c9797;
color: #ffffff;
border: 1px solid #837d7d;
border-top: 0 none;
line-height: 150%;
padding: 16px 20px;
font-size: 12px;
}
#cssmenu ul ul ul {
border-top: 0 none;
}
#cssmenu ul ul li {
position: relative;
}
#cssmenu ul ul li:first-child > a {
border-top: 1px solid #837d7d;
}
#cssmenu ul ul li:hover > a {
background: #b5b1b1;
color: #ffffff;
}
#cssmenu ul ul li:last-child > a {
-moz-border-radius: 0 0 3px 3px;
-webkit-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
-moz-box-shadow: 0 1px 0 #9c9797;
-webkit-box-shadow: 0 1px 0 #9c9797;
box-shadow: 0 1px 0 #9c9797;
}
#cssmenu ul ul li:last-child:hover > a {
-moz-border-radius: 0 0 0 3px;
-webkit-border-radius: 0 0 0 3px;
border-radius: 0 0 0 3px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
}
#cssmenu ul ul li.has-sub > a:after {
content: '+';
position: absolute;
top: 50%;
right: 15px;
margin-top: -8px;
}
#cssmenu ul li:hover > a,
#cssmenu ul li.active > a {
background: #9c9797;
color: #ffffff;
}
#cssmenu ul li.has-sub > a:after {
content: '+';
margin-left: 5px;
}
#cssmenu ul li.last ul {
left: auto;
right: 0;
}
#cssmenu ul li.last ul ul {
left: auto;
right: 99.5%;
}
#cssmenu a {
background: #333;
color: #CBCBCB;
padding: 0 20px;
}
#cssmenu > ul > li > a {
line-height: 48px;
font-size: 12px;
}
#cssmenu.align-center > ul {
text-align: center;
font-size: 0;
}
#cssmenu.align-center > ul > li {
display: inline-block;
float: none;
}
#cssmenu.align-center ul ul {
text-align: left;
}
#cssmenu.align-right > ul > li {
float: right;
}
#cssmenu.align-right ul ul {
left: auto;
right: 0;
text-align: right;
}
#cssmenu.align-right ul ul ul {
left: auto;
right: 190px;
}
#cssmenu.align-right ul ul li.has-sub > a:after {
left: 15px;
right: auto;
}
<html lang="ru" dir="ltr">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Icon Library -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
</head>
<body>
<div id="cssmenu">
<ul>
<li class="active"><i class="fa fa-fw fa-home"></i> Home</li>
<li class="has-sub"><i class="fa fa-fw fa-bars"></i> Menus
<ul>
<li class="has-sub">Menu 1
<ul>
<li>Menu 1.1</li>
<li>Menu 1.2</li>
<li>Menu 1.3</li>
<li class="has-sub">Menu 1.4
<ul>
<li>Menu 1.4.1</li>
<li>Menu 1.4.2</li>
<li>Menu 1.4.3</li>
<li>Menu 1.4.4</li>
</ul>
</li>
</ul>
</li>
<li class="has-sub">Menu 2
<ul>
<li>Menu 2.1</li>
<li>Menu 2.2</li>
<li>Menu 2.3</li>
</ul>
</li>
<li class="has-sub">Menu 3
<ul>
<li>Menu 3.1</li>
<li>Menu 3.2</li>
<li class="has-sub">Menu 3.3
<ul>
<li>Menu 3.3.1</li>
<li>Menu 3.3.2</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li><i class="fa fa-fw fa-cog"></i> About us</li>
<li><i class="fa fa-fw fa-phone"></i> Contact</li>
</ul>
</div>
</body>
</html>
Related
I need to display sub-sub-menu on hover of my sub-menu. So far I did code to display menu -> sub-menu on menu click, but to proceed I want a functionality to display sub-sub-menu on hover of my sub-menu. Can somebody help me to achieve the same?
var ddmenuitem = 0;
function jsddm_open() {
jsddm_close();
ddmenuitem = $(this).find('ul.submenu').css('display', 'block');
// $(this).find('div.subsubmenu').css('display','none');
}
function jsddm_close() {
if (ddmenuitem) ddmenuitem.css('display', 'none');
}
$(document).ready(function() {
$('#topnav > ul > li').bind('click', jsddm_open)
$('#topnav > ul > li > a').click(function(ev) {
if ($(this).hasClass('current')) {
ev.preventDefault();
}
if ($(this).attr('class') != 'active') {
$('#topnav ul li a').removeClass('active');
$(this).addClass('active');
}
});
});
#topnav {
float: left;
width: 600px;
height: 30px;
background: black;
margin-top: 10px;
position: relative;
font-size: 15px;
margin-left: 30px
}
#topnav ul {
list-style: none;
padding: 0px;
margin: 0px;
}
#topnav ul li {
float: left;
margin: 0;
padding: 0;
}
#topnav ul li a {
padding: 5px 15px;
color: red;
text-decoration: none;
display: block;
font-weight: bold;
}
#topnav ul li a:link {
color: red;
text-decoration: none;
}
#topnav ul li a:visited {
color: #FFF;
text-decoration: none;
}
#topnav ul li a:hover {
color: red;
text-decoration: none;
}
#topnav ul li a.active {
text-decoration: none;
color: black;
background: #e0e0e0;
}
#topnav ul li ul.submenu {
float: left;
padding: 4px 0;
position: absolute;
left: 0;
top: 30px;
display: none;
background: #e0e0e0;
color: #00537F;
width: 600px;
height: 30px;
}
#topnav ul li ul.submenu a {
display: inline;
color: #00537F;
padding: 4px 8px;
}
#topnav ul.submenu a:hover {
background-color: black;
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="topnav">
<ul>sds
<li>
Admin
</li>
<li>
MAC
<ul class="submenu">
<li>Master Data</li>
<li>
Transaction Data
<ul>
<li>Company Master</li>
<li>Location Master</li>
<li>Size Master</li>
</ul>
</li>
<li>
Admin Data
</li>
</ul>
</li>
</ul>
</div>
Try the following snippet without using jquery or javascript, you can get it done using only css. And have updated according to your question
#nav {
list-style: none inside;
margin: 0;
padding: 0;
text-align: center;
}
#nav li {
display: block;
position: relative;
float: left;
background: #000000;
}
#nav li a {
display: block;
padding: 0;
text-decoration: none;
width: 200px;
line-height: 35px;
color: #fff;
}
#nav li li a {
font-size: 80%;
}
#nav li:hover {
background: #ff0000;
}
#nav ul {
position: absolute;
padding: 0;
left: 0;
display: none;
}
#nav li:hover ul ul {
display: none;
}
#nav li:hover ul {
display: block;
}
#nav li li:hover ul {
display: block;
margin-left: 200px;
margin-top: -35px;
}
<div id="topnav">
<ul id="nav">
<li>
Admin
</li>
<li>
MAC
<ul class="submenu">
<li>Master Data</li>
<li>
Transaction Data ⇒
<ul>
<li>Company Master</li>
<li>Location Master</li>
<li>Size Master</li>
</ul>
</li>
<li>
Admin Data
</li>
</ul>
</li>
</ul>
</div>
you can try this
#menu {
background: #343434;
color: #eee;
height: 35px;
border-bottom: 4px solid #eeeded
}
#menu ul,
#menu li {
margin: 0 0;
padding: 0 0;
list-style: none
}
#menu ul {
height: 35px
}
#menu li {
float: left;
display: inline;
position: relative;
font: bold 12px Arial;
text-shadow: 0 -1px 0 #000;
border-right: 1px solid #444;
border-left: 1px solid #111;
text-transform: uppercase
}
#menu li:first-child {
border-left: none
}
#menu a {
display: block;
line-height: 35px;
padding: 0 14px;
text-decoration: none;
color: #eee;
}
#menu li:hover > a,
#menu li a:hover {
background: #111
}
#menu input {
display: none;
margin: 0 0;
padding: 0 0;
width: 80px;
height: 35px;
opacity: 0;
cursor: pointer
}
#menu label {
font: bold 30px Arial;
display: none;
width: 35px;
height: 36px;
line-height: 36px;
text-align: center
}
#menu label span {
font-size: 12px;
position: absolute;
left: 35px
}
#menu ul.menus {
height: auto;
width: 180px;
background: #111;
position: absolute;
z-index: 99;
display: none;
border: 0;
}
#menu ul.menus li {
display: block;
width: 100%;
font: 12px Arial;
text-transform: none;
}
#menu li:hover ul.menus {
display: block
}
#menu a.home {
background: #c00;
}
#menu a.prett {
padding: 0 27px 0 14px
}
#menu a.prett::after {
content: "";
width: 0;
height: 0;
border-width: 6px 5px;
border-style: solid;
border-color: #eee transparent transparent transparent;
position: absolute;
top: 15px;
right: 9px
}
#menu ul.menus a:hover {
background: #333;
}
#menu ul.menus .submenu {
display: none;
position: absolute;
left: 180px;
background: #111;
top: 0;
width: 180px;
}
#menu ul.menus .submenu li {
background: #111;
}
#menu ul.menus .has-submenu:hover .submenu {
display: block;
}
<nav>
<ul id='menu'>
<li><a class='home' href='/'>Home</a></li>
<li><a class='prett' href='#' title='Menu'>Menu</a>
<ul class='menus'>
<li class='has-submenu'><a class='prett' href='Dropdown 1' title='Dropdown 1'>Dropdown 1 + Sub Menu</a>
<ul class='submenu'>
<li>Sub Menu</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
</ul>
</li>
<li><a href='#' title='Dropdown 2'>Dropdown 2</a></li>
<li><a href='#' title='Dropdown 3'>Dropdown 3</a></li>
</ul>
</li>
</ul>
</nav>
In my blog (http://www.khyberacademy.blogspot.com), the dropdown menu is not working. Please guide me. The HTML & CSS codes are given below.
On hover it doesn't drop down and also I have tried to change the display to block & inline, but it didn't solve my problem.
HTML:
<!-- begin #topMenu -->
<div class='clearfix' id='navigation-wrapper'>
<select id='responsive-main-nav-menu' onchange='javascript:window.location.replace(this.value);'><option selected='selected'>Menu</option></select>
<nav class='main-menu' id='main-navigation'>
<ul class='sf-menu' id='menu-top-menu'>
<li>
<a href='#' style='padding-right: 23px;'>Engineering<span class='downarrowclass'/></a>
<ul class='sub-menu' style='top: 127px; visibility: visible; left: 0px; width: 175px; display: none;'>
<li><a href='http://khyberacademy.blogspot.com/search/label/Bridge%20Engineering'>Bridge Engineering</a></li>
<li><a href='http://khyberacademy.blogspot.com/search/label/Pre-stressed%20Concrete'>Pre-stressed Concrete</a></li>
<li><a href='http://khyberacademy.blogspot.com/search/label/CAD%2FCAM'>CAD/CAM</a></li>
</ul>
</li>
<li>
<a href='#' style='padding-right: 23px;'>COMMERCE<span class='downarrowclass'/></a>
<ul class='sub-menu' style='top: 127px; visibility: visible; display: none;'>
<li><a href='http://khyberacademy.blogspot.com/search/label/AUDITING'>AUDITING</a></li>
<li><a href='http://khyberacademy.blogspot.com/search/label/Business%20Communication'>BUSINESS COMMUNICATION</a></li>
<li><a href='http://khyberacademy.blogspot.com/search/label/ECONOMICS'>ECONOMICS</a></li>
<li><a href='http://khyberacademy.blogspot.com/search/label/STATISTICS'>STATISTIC</a></li>
</ul>
</li>
<li>
<a href='#' style='padding-right: 23px;'>COMPUTER<span class='downarrowclass'/></a>
<ul class='sub-menu' style='top: 127px; visibility: visible; display: none;'>
<li><a href='http://khyberacademy.blogspot.com/search/label/Joomla%21'>JOOMLA</a></li>
<li><a href='http://khyberacademy.blogspot.com/search/label/Windows%20Tricks'>WINDOWS TRICKS</a></li>
<li><a href='#'>WORDPRESS</a></li>
<li><a href='#'>BLOGGING</a></li>
</ul>
</li>
<li>
<a href='#' style='padding-right: 23px;'>GRAPHICS<span class='downarrowclass'/></a>
<ul class='sub-menu' style='top: 127px; visibility: visible; display: none;'>
<li><a href='http://khyberacademy.blogspot.com/search/label/CAD%2FCAM'>CAD/CAM</a></li>
</ul>
</li>
<li>
<a href='http://khyberacademy.blogspot.com/p/contact-us.html'>Contact</a>
</li>
</ul>
</nav>
</div>
<!-- end #topMenu -->
CSS:
/* -------------------------------------------------- */
/* MAVIGATION
/* -------------------------------------------------- */
.downarrowclass {
position: absolute;
top: 53px;
right: 5px;
}
.rightarrowclass {
position: absolute;
top: 10px;
right: 10px;
}
#main-navigation select { display: none }
#main-navigation { float: right }
#main-navigation > ul { margin: -30px 0 0 0px }
#main-navigation ul li {
list-style: none;
float: left;
position: relative;
}
#main-navigation li a {
color: #898989;
font-family: 'Dosis', 'Verdana', sans-serif;
font-size: 16px;
font-weight: normal;
padding: 47px 12px 50px 12px;
margin: 0px 0px 10px 0;
position: relative;
text-align: center;
text-transform: uppercase;
float: left;
overflow: hidden;
line-height: 20px;
}
#main-navigation ul li a:hover,
#main-navigation ul li.current-menu-ancestor > a,
#main-navigation ul li.current-menu-item > a {
color: #9dcedf;
background: #f8f8f8;
border-bottom: 1pt solid #9dcedf;
}
#main-navigation ul ul li a {
display: block;
float: none;
}
#main-navigation ul ul {
background: url("http://1.bp.blogspot.com/-iIDMdP-Ub9I/UkEjY7k9a5I/AAAAAAAAJ-0/ZWPPe0dkcoA/s1600/menu-drop-bg.png") 20% 0% no-repeat;
padding-top: 8px;
display: none;
left: 0;
margin-top: -18px;
position: absolute;
width: 175px;
z-index: 99;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
#main-navigation ul ul ul {
background: url("http://1.bp.blogspot.com/-3LBiTw7Ht0U/UkEjYHu05eI/AAAAAAAAJ-k/pCHPYKrpKak/s1600/menu-drop-bg-2.png") 0% 50% no-repeat;
padding-left: 8px;
display: none;
left: 0;
position: absolute;
width: 175px;
z-index: 99;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
#main-navigation ul ul ul ul {
background: url("http://1.bp.blogspot.com/-3LBiTw7Ht0U/UkEjYHu05eI/AAAAAAAAJ-k/pCHPYKrpKak/s1600/menu-drop-bg-2.png") 0% 50% no-repeat;
padding-left: 8px;
display: none;
margin-left: 10px;
left: 0;
position: absolute;
width: 175px;
z-index: 99;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
}
#main-navigation ul ul li,
#main-navigation ul ul li a {
padding: 0px 0 0 0px;
margin: 0px;
color: #FFF;
background: #615951;
font-family: "Arial", "Verdana";
}
#main-navigation ul ul li { }
#main-navigation ul ul li { float: none }
#main-navigation ul li {
padding: 0;
margin: 0 0 0 20px;
}
#main-navigation ul ul a {
border: 0;
color: #fff;
display: block;
font-size: 11px;
font-weight: 400;
padding: 5px 10px !important;
text-align: left;
margin: 0;
text-transform: none;
}
#main-navigation ul ul a:hover,
#main-navigation ul ul .hover > a,
#main-navigation ul ul .current-menu-item > a,
#main-navigation ul ul .current-menu-item > a:hover {
background: #9dcedf ;
color: #fff !important;
border: 0 !important;
}
#main-navigation ul li ul {
position: absolute;
left: 0px;
display: block;
visibility: hidden;
margin-left: 0px;
top: 0;
}
.downarrowclass,
.rightarrowclass {
width:8px;
height:8px;
background:url(http://2.bp.blogspot.com/-bkf-TLVpTn4/UkEjaEMyKaI/AAAAAAAAJ_E/dyM2NDVqNNo/s1600/plus.png) top left no-repeat;
display:inline-block;
position: absolute;
right: 5px;
top: 53px
}
.rightarrowclass {
background-image:url(http://3.bp.blogspot.com/-ivF1y3GR6rw/UkEjZ8YMXlI/AAAAAAAAJ-8/xCB_X7XVIbw/s1600/plus-white.png);
}
Just Add this class, it will work well.
Hopefully, this will resolve your issue.
#main-navigation ul li:hover ul{display:block!important;}
Remove display:none in every "ul"
and set visiblity:none. Then add below Javascript code.
$("ul").hover(function(){
$(this).css("visibility", "visibile");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
I am trying to create a drop down navigation that you can see the sub menu within the drop down a little like this![enter image description here
I have the essential layout i want though i am failing to actually create the drop down float left.
HTML
<div id='cssmenu'>
<ul>
<li><a href='#'><span>Home</span></a></li>
<li><a href='#'><span>Services</span></a>
<div class="sub">
<div class="subinner">
<ul>
<li><a href='#'><span>Consultancy</span></a></li>
<li><a href='#'><span>Project Managment & Execution</span></a></li>
<li><a href='#'><span>Commissioning</span></a></li>
</ul>
<ul>
<li>Training</li>
<li>Plant Performance Enchancement</li>
</ul>
</div> <!-- End of Sub -->
</div> <!-- End of Subinner -->
</li>
<li class='sub'><a href='#'><span>About</span></a>
<div class="sub">
<div class="subinner">
<ul>
<li><a href='#'><span>Company</span></a></li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
</div>
</div>
</li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
</div>
Below is the CSS controls the drop down no JS is used.
#cssmenu ul {
margin: 0;
padding: 7px 6px 0;
background: #493B88;
line-height: 100%;
width: auto;
}
#cssmenu li {
margin: 0 5px;
padding: 0 0 8px;
float: left;
position: relative;
list-style: none;
}
#cssmenu a,
#cssmenu a:link {
font-weight: bold;
font-size: 13px;
color: #e7e5e5;
text-decoration: none;
display: block;
padding: 8px 20px;
margin: 0;
}
#cssmenu a:hover {
background: #000;
color: #000;
}
#cssmenu .active a,
#cssmenu li:hover > a {
background: #ccc;
color: #000;
}
#cssmenu ul ul li:hover a,
#cssmenu li:hover li a {
background: none;
border: none;
color: #000;
width: 30%;
}
#cssmenu ul ul a:hover {
background: #7d7d7d;
color: #000 !important;
width: 400px;
}
#cssmenu li:hover > .sub .subinner ul {
display: block;
position: absolute;
left: 0;
}
#cssmenu ul ul {
z-index: 1000;
display: none;
margin: 0;
padding: 0;
width: 300px;
position: absolute;
top: 40px;
left: 0;
background: #ffffff;
border: solid 1px #b4b4b4;
}
#cssmenu ul ul li {
float: none;
margin: 0;
padding: 3px;
}
#cssmenu ul ul a,
#cssmenu ul ul a:link {
font-weight: normal;
font-size: 12px;
}
#cssmenu ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
* html #cssmenu ul {
height: 1%;
}
Here is a link to view my drop down menu Live
https://jsfiddle.net/pj8kL8dL/
I have spent 2-3 hours to get this result, i hope it is what you need.
By the way, I would avoid using position:something so often.
It seems a responsive one, did you like the result?
body{
margin: 0;
}
#cssmenu ul {
margin: 0;
}
#cssmenu ul > li {
margin: 0 5px;
padding: 0 0 8px;
float: left;
list-style: none;
}
#cssmenu ul > ul li {
margin: 0 5px;
padding: 0 0 8px;
float: none;
list-style: none;
}
#cssmenu a,
#cssmenu a:link {
font-weight: bold;
font-size: 13px;
color: #e7e5e5;
text-decoration: none;
display: block;
padding: 8px 20px;
margin: 0;
}
#cssmenu a:hover {
background: #000;
color: #000;
}
#cssmenu .active a,
#cssmenu li:hover > a {
background: #ccc;
color: #000;
}
#cssmenu ul ul li:hover a,
#cssmenu li:hover li a {
background: none;
border: none;
color: #000;
}
#cssmenu ul ul a:hover {
background: #7d7d7d;
color: #000 !important;
}
#cssmenu li:hover > .sub .subinner ul {
display: block;
}
#cssmenu ul ul {
z-index: 1000;
display: none;
margin: 0;
padding: 0;
background: #ffffff;
border-bottom: solid 1px #b4b4b4;
border-top: solid 1px #b4b4b4;
}
#cssmenu ul ul li {
float: left;
margin: 0;
padding: 3px;
}
#cssmenu li:nth-child(2) ul ul li {
float: none;
margin: 0;
padding: 3px;
}
#cssmenu li:nth-child(2) ul ul li a{
border-bottom: 1px solid #B4B4B4;
}
#cssmenu ul ul a,
#cssmenu ul ul a:link {
font-weight: normal;
font-size: 12px;
}
#cssmenu ul:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
* html #cssmenu ul {
height: 1%;
}
#cssmenu ul li:nth-child(2) .subinner{
top: 47px;
position: absolute;
left: 0px;
width: 100%;
}
#cssmenu ul li:nth-child(3) .subinner{
top: 47px;
position: absolute;
left: 0px;
width: 100%;
}
#cssmenu{
margin: 0px;
padding: 7px 6px 0px;
background: #493B88 none repeat scroll 0% 0%;
line-height: 100%;
width: auto;
height: 40px;
}
#cssmenu li:nth-child(2):hover > .sub .subinner ul {
width: 100%;
}
#cssmenu li:hover > .sub .subinner ul {
width: 100%;
}
#cssmenu .subinner ul ul{
float: left;
width: 33% !important;
border: none;
}
<div id='cssmenu'>
<ul>
<li><a href='#'><span>Home</span></a></li>
<li><a href='#'><span>Services</span></a>
<div class="sub">
<div class="subinner">
<ul>
<ul>
<li><a href='#'><span>Consultancy</span></a></li>
<li><a href='#'><span>Project Managment & Execution</span></a></li>
</ul>
<ul>
<li><a href='#'><span>Commissioning</span></a></li>
<li><span>Training</span></li>
<li><span>Plant Performance Enchancement</span></li>
</ul>
<ul>
<li><a href='#'><span>Something</span></a></li>
<li><a href='#'><span>Something</span></a></li>
</ul>
</ul>
</div> <!-- End of Sub -->
</div> <!-- End of Subinner -->
</li>
<li class='sub'><a href='#'><span>About</span></a>
<div class="sub">
<div class="subinner">
<ul>
<li><a href='#'><span>Company</span></a></li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
</div>
</div>
</li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
</div>
Remove the position: relative; in #cssmenu li so the sub menu will be relative to any outer div or body.
Also increase width of sub menu to 100% in #cssmenu ul ul
I have a problem with the drop down menu style..
when I mouse hover the third level, the second level font color is changed to its color..
I want to make it keep white (as hover) when third level is hover..
How can I make it?
My style:
<!DOCTYPE html>
<html>
<head>
<style>
ul#menu
{
font-size: 20px;
display: inline;
min-height: 45px;
overflow: auto;
}
ul#menu li
{
float: left;
list-style: none;
padding-left: 20px;
background-color: #ff6a00;
border-bottom: 2px solid #181818;
border-top: 2px solid #303030;
min-width: 160px;
display: block;
position: relative;
min-height: 45px;
}
ul#menu li:hover
{
background-color: #808080;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#1c1c1c', endColorstr='#1b1b1b');
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr='#1c1c1c', endColorstr='#1b1b1b')";
border-bottom: 2px solid #222222;
border-top: 2px solid #1B1B1B;
}
ul#menu li a
{
text-decoration: none;
padding: 0px;
border-left: 3px solid rgba(0, 0, 0, 0);
color: white;
display: block;
font-family: 'Lucida Console';
font-size: 18px;
line-height: 45px;
padding: 0 10px;
text-decoration: none;
text-transform: uppercase;
text-align: left;
}
ul#menu li a:hover
{
border-radius: 5px 0 0 0;
border-left: 3px solid #C4302B;
color: #C4302B;
}
ul#menu li:hover
{
background-color: #DA251D;
}
ul#menu li ul
{
display: none;
}
ul#menu li:hover ul
{
display: block;
}
ul#menu li ul li
{
float: none;
}
#menu .submenu li:hover a
{
border-left: 3px solid #454545;
border-radius: 0;
color: #ffffff;
}
#menu > li:hover .submenu, .menu > li:focus .submenu
{
max-height: 2000px;
z-index: 10;
}
#menu > li:hover .submenu li, .menu > li:focus .submenu li
{
opacity: 1;
-webkit-transform: none;
-moz-transform: none;
-ms-transform: none;
-o-transform: none;
transform: none;
}
</style>
<title>Page Title</title>
</head>
<body>
<div class="ThirdMenu">
<ul id="menu" class="menu">
<li>sangeet
<ul class="submenu" id="submenu"
<li>sdfsadf
<ul class="thirdmenu" id="thirdmenu"><li>sdfsd</li></ul>
</li>
<li></li>
<li></li>
<li></li>
</ul>
</li>
</ul>
</div>
</div>
</body>
</html>
Tell me simple way to display third menu hover on main category?
if i got you right:
HTML:
<div class="menu_wrap">
<ul class="newlevel level0">
<li>level0, link 1</li>
<li>
level0, link 2
<ul class="newlevel level1">
<li>level1, link 1</li>
<li>level1, link 2</li>
<li>
level1, link 3
<ul class="newlevel level2">
<li>level2, link 1</li>
<li>level2, link 2</li>
<li>level2, link 3</li>
</ul>
</li>
</ul>
</li>
<li>level0, link 3</li>
</ul>
</div>
CSS:
.menu_wrap
{
width: 300px;
}
ul
{
padding: 0;
}
li
{
list-style: none;
}
a
{
display: block;
padding: 10px;
text-decoration: none;
background: #ff6a00;
color: #000;
border-top: 1px solid;
}
a:hover, .current > a
{
background: #DA251D;
}
.level1 a
{
padding-left: 40px;
}
.level2 a
{
padding-left: 80px;
}
.level0 ul
{
display: none;
}
.newlevel li:hover > ul
{
display: block;
}
JQuery:
$(document).ready(function(){
$('.newlevel li').hover(function(){
if ($(this).children('ul').length > 0){
$(this).addClass('current');
}
},function(){
$(this).removeClass('current');
});
});
jsfiddle: http://jsfiddle.net/esf90kz5/3/
I am working on a menu bar for a web site and the dropdown menu's work fine, the only problem is they will only display when my mouse is right at the edge of where they come out. Can anyone help, would be much appreciated. The part that you have to hover over is the very bottom of the red areas, and on dropdown 1 another submenu at the bottom to the right.
Here is my code:
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<link rel="shortcut icon" href="#"/>
</head>
<body>
<div id="banner">
<p id="title">Code Works</p>
</div>
<center>
<div style="background-color: #FFFF00" id="display">=</div>
</center>
<nav>
<ul>
<li>Home</li>
<li>Tutorials
<ul>
<li>HTML</li>
<li>CSS</li>
<li>Setting Up +
<ul>
<li>Programs</li>
<li>Files</li>
</ul>
</li>
</ul>
</li>
<li>Templates +
<ul>
<li>Web Page</li>
<li>Clocks</li>
<li>Calendars</li>
<li>Maps</li>
<li>Transitions</li>
<li>Video</li>
<li>Audio</li>
<li>Search</li>
</ul>
</li>
<li>Contact Us</li>
</ul>
</nav>
**CSS**
html {
height: 100%;
}
body {
background: linear-gradient(#C0C0C0, #E0E0E0);
height: 100%;
margin: 0;
background-repeat: no-repeat;
background-attachment: fixed;
}
#banner
{
width: 1376px;
margin-left: -10px;
margin-right: -10px;
margin-top: -32px;
padding-top: 0px;
background-color: #3366CC;
background-size: 100%;
height: 80px;
border-bottom: 4px inset #254A93;
background: linear-gradient(#3366CC, #2952A3);
}
#title
{
padding-top: 0.7em;
color: #FFFF00;
text-align: center;
font-size: 32px;
}
nav ul ul
{
display: none;
}
nav ul li:hover > ul
{
display: block;
}
nav ul
{
opacity: 0;
margin-top: -1px;
margin-left: -10px;
background: linear-gradient(#FFFF66, #FFFF00);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 0px;
list-style: none;
position: relative;
display: inline-table;
}
nav ul:after
{
content: ""; clear: both; display: block;
}
nav ul li
{
float: left;
}
nav ul li:hover
{
border-bottom: 4px solid #FF0000;
background: linear-gradient (#FFFF66, #FFFF00);
border-top: 2px solid #FFFF66;
}
nav ul li:hover a
{
color: #3366CC;
}
nav ul li a
{
display: block; padding: 25px 40px;
color: #757575; text-decoration: none;
}
nav ul ul
{
width: 200px;
background: #FFFF00; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li
{
border: 2px outset #FFFF00;
background: linear-gradient(#FFFF66, #FFFF00);
float: none;
position: relative;
}
nav ul ul li a
{
padding: 15px 40px;
color: #757575;
}
nav ul ul li a:hover
{
border-top: #E0E0E0;
border-bottom: #E0E0E0;
background: linear-gradient(#FFFF00, #FFFF66);
}
nav ul ul ul
{
position: absolute; left: 100%; top:0;
}
p:hover ul
{
display: none;
}
nav ul:hover
{
opacity: 0.7;
}
nav ul:hover nav ul li
{
opacity: 0.7;
}
#display
{
opacity: 0.7;
height: 30px;
background: linear-gradient(#FFFF00, #FFFF66);
}
#display a
{
size: 32px;
text-decoration: none;
}
nav ul ul li:hover
{
border-top: 1px solid #E0E0E0;
border-bottom: 1px solid #E0E0E0;
}
I think there are some redundant CSS in your code, but to make it work, you just need to add the line opacity:0.7 to this CSS:
nav ul li:hover > ul {
display:block;
opacity:0.7;
}
Here is the working fiddle