Sub Nav doesnt display below horizontally - html

I am creating a nav bar with further sub lists. The first sub list displays exactly how I want it, but the one below that does not. Rather than display horizontally below the initial sub nav bar, it displays vertically and to the right of it.
Does anyone have any idea why this is, I believe I am missing something but for the life of me cant find it.
I added a photo to explain what I would like. The red should appear where the blue is.
Appreciate your time!
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
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 {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 8px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
nav ul ul.ul-right {
right: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul class="ul-right">
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>

If You have no problem setting the width of the ul this might be a solution:
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
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 {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 8px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
top: 100%;
width: 578px;
}
nav ul ul.ul-right {
right: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul class="ul-right">
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>

Related

Navigation Submenu is not coming up

I have created a Navigation menu with sub menu. Can anyone please help me to find out why sub menu is coming as part of main menu?
Navigation have options like: Home, About, My Portfolio...
My Portfolio have menu options: Web Development, Motion...
Issue: Web Development should have sub menu: Bootstrap, CSS but rather it is coming as part of main menu.<div id="Navigation"><ul class="Navigation"><li>Home</li></ul>/div>
body {
background: #c4c7cb;
background-image: -webkit-radial-gradient(cover, #FFF, #D1D1D1);
background-image: -moz-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: -o-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: radial-gradient(cover, #e8eaec, #a4a8ae)
}
html {
min-height: 100%;
}
.Navigation {
height: 50px;
padding: 0;
margin: 0;
position: absolute;
}
.Navigation li {
height: auto;
width: 150px;
float: left;
text-align: center;
list-style: none;
font: 12px"Bonveno", "Century Gothic";
padding: 0;
margin: 0;
background-color: #eee;
border: 1px solid #ccc;
box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 1px 3px rgba(0, 0, 0, .1);
border-radius: 3px;
margin-left: 10px;
}
.Navigation a {
padding: 13px;
text-decoration: none;
color: #333;
text-shadow: 0 1px #fff;
display: block;
}
.Navigation li ul {
display: none;
height: auto;
margin-left: -11px;
padding: 0;
}
.Navigation li:hover ul {
display: block;
}
.Navigation li:hover,
a:hover {
background: #e8e8e8;
}
<div id="Navigation">
<ul class="Navigation">
<li>Home
</li>
<li>About
</li>
<li>My Portfolio
<ul>
<li>Web Development
<ul>
<li>Bootstrap
</li>
<li>CSS
</li>
</ul>
</li>
<li>Motion Graphics
</li>
<li>Flash Animation
</li>
<li>Logo Design
</li>
<li>Photography
</li>
</ul>
</li>
<li>Services
</li>
<li>Contact
</li>
</ul>
</div>
It is because you have a CSS rule for .Navigation li:hover ul { display: block; } that I believe you want to show the second level menu on first level item hover. But this rule is also applying to the third level menu (that means all ul under the first level item hovers are applied display: block;), you may want to use
.Navigation li:hover > ul instead
Try this...
body {
background: #c4c7cb;
background-image: -webkit-radial-gradient(cover, #FFF, #D1D1D1);
background-image: -moz-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: -o-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: radial-gradient(cover, #e8eaec, #a4a8ae)
}
html {
min-height: 100%;
}
.Navigation {
height: 50px;
padding: 0;
margin: 0;
position: absolute;
}
.Navigation li {
height: auto;
width: 150px;
float: left;
text-align: center;
list-style: none;
font: 12px"Bonveno", "Century Gothic";
padding: 0;
margin: 0;
background-color: #eee;
border: 1px solid #ccc;
box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 1px 3px rgba(0, 0, 0, .1);
border-radius: 3px;
margin-left: 10px;
}
.Navigation a {
padding: 13px;
text-decoration: none;
color: #333;
text-shadow: 0 1px #fff;
display: block;
}
.Navigation li ul {
display: none;
height: auto;
margin-left: -11px;
padding: 0;
}
.Navigation li ul li ul {
display: none !important;
height: auto;
margin-left: -11px;
padding: 0;
}
.Navigation li:hover ul {
display: block;
}
.Navigation li ul li:hover ul {
display: block !important;
}
.Navigation li:hover,
a:hover {
background: #e8e8e8;
}
<div id="Navigation">
<ul class="Navigation">
<li>Home
</li>
<li>About
</li>
<li>My Portfolio
<ul>
<li>Web Development
<ul>
<li>Bootstrap
</li>
<li>CSS
</li>
</ul>
</li>
<li>Motion Graphics
</li>
<li>Flash Animation
</li>
<li>Logo Design
</li>
<li>Photography
</li>
</ul>
</li>
<li>Services
</li>
<li>Contact
</li>
</ul>
</div>
body {
background: #c4c7cb;
background-image: -webkit-radial-gradient(cover, #FFF, #D1D1D1);
background-image: -moz-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: -o-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: radial-gradient(cover, #e8eaec, #a4a8ae)
}
html {
min-height: 100%;
}
.Navigation {
height: 50px;
padding: 0;
margin: 0;
position: relative;
}
.Navigation li {
height: auto;
width: 150px;
float: left;
text-align: center;
list-style: none;
font: 12px"Bonveno", "Century Gothic";
padding: 0;
margin: 0;
background-color: #eee;
border: 1px solid #ccc;
box-shadow: 0 1px 0 rgba(255, 255, 255, .9) inset, 0 1px 3px rgba(0, 0, 0, .1);
border-radius: 3px;
margin-left: 10px;
}
.Navigation a {
padding: 13px;
text-decoration: none;
color: #333;
text-shadow: 0 1px #fff;
display: block;
}
.Navigation li ul {
display: none;
height: auto;
margin-left: -11px;
padding: 0;
position: absolute;
}
.Navigation li ul li ul {
display: none !important;
height: auto;
margin-left: -11px;
padding: 0;
}
.Navigation li:hover ul {
display: block;
}
.Navigation li ul li:hover ul {
display: block !important;
}
.Navigation li:hover,
a:hover {
background: #e8e8e8;
}
<div id="Navigation">
<ul class="Navigation">
<li>Home
</li>
<li>About
</li>
<li>My Portfolio
<ul>
<li>Web Development
<ul>
<li>Bootstrap
</li>
<li>CSS
</li>
</ul>
</li>
<li>Motion Graphics
</li>
<li>Flash Animation
</li>
<li>Logo Design
</li>
<li>Photography
</li>
</ul>
</li>
<li>Services
</li>
<li>Contact
</li>
</ul>
</div>
You'll just need to adjust your on-hover state rules so that they apply to elements you need to when you need it to.
.Navigation li:hover > ul {
display: block;
}
.Navigation li > ul li:hover > ul {
display: block;
}
See snippet below (note: I've reduced menu item widths slightly to fit them into the preview pane)
.Navigation li > ul li > ul {
position: absolute;
top: 0px;
left: 127px;
}
.Navigation li > ul li > ul li {
float: none;
}
.Navigation li > ul li {
position: relative;
}
body{
background: #c4c7cb;
background-image: -webkit-radial-gradient(cover, #FFF,#D1D1D1 );
background-image: -moz-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: -o-radial-gradient(cover, #e8eaec, #a4a8ae);
background-image: radial-gradient(cover, #e8eaec, #a4a8ae)
}
html{
min-height:100%;
}
.Navigation{
height: 50px;
padding: 0;
margin: 0;
position: absolute;
}
.Navigation > li:first-child {
margin: 0px;
}
.Navigation li {
height: auto;
width: 115px;
float: left;
text-align: center;
list-style: none;
font:12px "Bonveno", "Century Gothic";
padding: 0;
margin: 0;
background-color: #eee;
border: 1px solid #ccc;
box-shadow: 0 1px 0 rgba(255,255,255, .9) inset, 0 1px 3px rgba(0,0,0, .1);
border-radius: 3px;
margin-left:10px;
}
.Navigation a{
padding:13px;
text-decoration: none;
color:#333;
text-shadow: 0 1px #fff;
display: block;
}
.Navigation li ul{
display: none;
height: auto;
margin-left: -11px;
padding: 0;
}
.Navigation li:hover > ul {
display: block;
}
.Navigation li > ul li:hover > ul {
display: block;
}
.Navigation li:hover, a:hover {
background: #e8e8e8;
}
<div id="Navigation">
<ul class="Navigation">
<li>Home</li>
<li>About</li>
<li>My Portfolio
<ul>
<li>Web Development
<ul>
<li>Bootstrap</li>
<li>CSS</li>
</ul>
</li>
<li>Motion Graphics</li>
<li>Flash Animation</li>
<li>Logo Design</li>
<li>Photography</li>
</ul>
</li>
<li>Services</li>
<li>Contact</li>
</ul>
</div>
From here, you can simply add further styles (if necessary) to sub-menu items 2 levels, or deeper, to appear to the right of the parent menu item (rather than below).
Align sub-menu to right:
The rules below serve only to demonstrate how to get you there. I'd recommend refining them.
.Navigation li > ul li > ul {
position: absolute;
top: 0px;
left: 127px;
}
.Navigation li > ul li > ul li {
float: none;
}
.Navigation li > ul li {
position: relative;
}

Horizontal Nav Bar Sub Navs Wrapping Down instead of using space behind(left) of it

So the problem I have is that if I select the last option on my nav bar, because the drop down has so many options, it exceeds the length left of the nav bar and wraps underneath, creating a grid of options 2x2.
I would much prefer if it used the space to the left rather than wrapping down. how can I make this possible.
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
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 {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul>
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>
The problem is that the submenu is aligned on the left edge of the parent item in the main menu. Let's align the submenu on the right edge of the main menu.
Add class ul-right to the corresponding <ul>.
Add CSS-code nav ul ul.ul-right { right: 0; }.
Check the result:
nav {
margin: 0 auto;
text-align: center;
}
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
color: white;
background: #787878;
background: linear-gradient(top, #787878 0%, #272727 100%);
background: -moz-linear-gradient(top, #787878 0%, #272727 100%);
background: -webkit-linear-gradient(top, #787878 0%, #272727 100%);
box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.15);
padding: 0 20px;
border-radius: 25px;
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 {
background: #A8A8A8;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block;
padding: 15px 50px;
color: white;
text-decoration: none;
}
nav ul ul {
background: #505050;
border-radius: 0px;
padding: 0;
position: absolute;
top: 100%;
}
nav ul ul.ul-right {
right: 0;
}
nav ul ul li {
float: left;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #A8A8A8;
}
nav ul ul ul {
position: absolute;
left: 100%;
top: 0;
}
<nav>
<ul>
<li>Players
<ul>
<li>Wonderkids
</li>
<li>Cheap Players
</li>
<li>Player Comparisons
</li>
</ul>
</li>
<li>Clubs
<ul>
<li>Club Info
</li>
<li>Transfer Budgets
</li>
<li>Sugar Daddys
</li>
</ul>
</li>
<li>Downloads
<ul>
<li>Tactics
</li>
<li>Shortlists
<ul>
<li>Various Shortlists
</li>
<li>Positional Shortlists
</li>
<li>Staff Shortlists
</li>
</ul>
</li>
</ul>
</li>
<li>Write-Ups
</li>
<li>Social
<ul class="ul-right">
<li>Facebook
</li>
<li>Twitter
</li>
<li>Youtube
</li>
<li>Affiliates
</li>
</ul>
</li>
<li>About Us
</li>
</ul>
</nav>

how to make my menu width 100% of the browser using css

I can't seem to get my menu 100% of the browser. I want a logo beside the menu in the header to. I tried in the CSS to add a background colour and width or 100% but this didn't work
Here is my code
#logo {
padding-top: 10px;
padding-left: 85px;
float: left;
}
/*----- Top Level -----*/
#menu2 {
background: #3b3b3b;
}
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu > ul > li > a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a,
.menu > ul > .current-item > a {
background: #2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2728;
}
.sub-menu li {
display: block;
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #3e3436;
}
<div id="menu2">
<div id="logo">
<img src="logo2.png" alt="logo" />
</div>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home
</li>
<li>About Us
</li>
<li>
What's On
<ul class="sub-menu">
<li>Sunday Services
</li>
<li>Speical Events
</li>
<li>Sunday School
</li>
<li>Youth Group
</li>
<li>Prayer Meeting
</li>
<li>Coffee Morning
</li>
<li>Woman's Fellowship
</li>
<li>Craft Class
</li>
<li>Diners Club
</li>
</ul>
</li>
<li>Get In Touch
</li>
<li class="current-item">Find Us
</li>
</ul>
</nav>
</div>
You just need to clear the floats: It's call a clearfix
There are many method of doing this...one is to add overflow:hidden to the wrapper
#menu2 {
background: #3b3b3b;
overflow: hidden;
/* quick clearfix */
}
Codepen Demo
#logo {
padding-top: 10px;
padding-left: 85px;
float: left;
}
/*----- Top Level -----*/
#menu2 {
background: #3b3b3b;
overflow: hidden;
/* quick clearfix */
}
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 19px;
}
.menu > ul > li > a {
padding: 10px 40px;
display: inline-block;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a,
.menu > ul > .current-item > a {
background: #2e2728;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2728;
}
.sub-menu li {
display: block;
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover,
.sub-menu .current-item a {
background: #3e3436;
}
<div id="menu2">
<div id="logo">
<img src="logo2.png" alt="logo" />
</div>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Home
</li>
<li>About Us
</li>
<li>
What's On
<ul class="sub-menu">
<li>Sunday Services
</li>
<li>Speical Events
</li>
<li>Sunday School
</li>
<li>Youth Group
</li>
<li>Prayer Meeting
</li>
<li>Coffee Morning
</li>
<li>Woman's Fellowship
</li>
<li>Craft Class
</li>
<li>Diners Club
</li>
</ul>
</li>
<li>Get In Touch
</li>
<li class="current-item">Find Us
</li>
</ul>
</nav>
</div>
The background in the css should be background-color: #FFFFFF

CSS Drop Down issue

I have a very big issue with the Drop Down menu i have used the Css and HTML for the same.
The problem what i am facing is i need the background width of the nav to be 100% to the ontainer but niw when i am increasing the horizontal menu its shifting to next line
can you please help
body{
margin: 0;
padding: 0;
font-family: Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 87.5%;
}
.container{
width: 70%;
margin: 0 auto;
clear: both;
border:10px solid #0171bd;
}
.nav ul ul {
display: none;
}
.nav ul li:hover > ul {
display: block;
}
.nav ul {
background: #efefef;
background: linear-gradient(top, #0077bb 0%, #0171bd 100%);
background: -moz-linear-gradient(top, #0077bb 0%, #0171bd 100%);
background: -webkit-linear-gradient(top, #0077bb 0%,#0171bd 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 10px;
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 {
background: #bee6ff;
background: linear-gradient(top, #bee6ff 0%, #7dcdff 40%);
background: -moz-linear-gradient(top, #bee6ff 0%, #ffffff 50%);
background: -webkit-linear-gradient(top, #bee6ff 0%,#7dcdff 40%);
}
.nav ul li:hover a {
color: #363636;
}
.nav ul li a {
display: block; padding: 20px 12px;
color: #ffffff; text-decoration: none;
}
.nav ul ul {
background: #bee6ff;
background: linear-gradient(top, #bee6ff 0%, #7dcdff 40%);
background: -moz-linear-gradient(top, #bee6ff 0%, #ffffff 50%);
background: -webkit-linear-gradient(top, #bee6ff 0%,#7dcdff 40%);
border-radius: 0px;
padding: 0;
position: absolute; top: 100%;
}
.nav ul ul li {
float: none;
border-top: 1px solid #6cbdef;
border-bottom: 1px solid #6cbdef;
position: relative;
}
.nav ul ul li a {
padding: 15px 10px;
color: #fff;
}
.nav ul ul li a:hover {
background: #0075bb;
color:#FFF;
}
.nav ul ul ul {
position: absolute; left: 100%; top:0;
}
HTML Code is like below
<div class="container">
<div class="nav">
<ul>
<li>
Home</li>
<li>
Site Settings
<ul>
<li>Add Meta Tags</li>
<li>Add Page Title</li>
</ul>
</li>
<li>User Managment</li>
<li>
Upload Images
<ul>
<li>Upload Slider Image</li>
<li>Upload Ads Image</li>
</ul>
</li>
<li>Content Managment</li>
<li>
Devotees
<ul>
<li>Add Devotee</li>
<li>Edit Devotee</li>
</ul>
</li>
<li>
News
<ul>
<li>Add News</li>
<li>Edit News</li>
</ul>
</li>
<li>
Donation
<ul>
<li>View Request</li>
<li>Approve Request</li>
</ul>
</li>
<li>
Blogs
<ul>
<li>Add Blog</li>
<li>Edit Blog</li>
</ul>
</li>
</ul>
</div>
</div>
here is answer for same
.nav ul ul {
width: auto;
}
Please check once
body{
margin: 0;
padding: 0;
font-family: Helvetica, Arial, "Lucida Grande", sans-serif;
font-size: 87.5%;
}
.container{
width: 70%;
margin: 0 auto;
clear: both;
border:10px solid #0171bd;
}
.nav ul ul {
display: none;
}
.nav ul li:hover > ul {
display: block;
}
.nav ul {
background: #efefef;
background: linear-gradient(top, #0077bb 0%, #0171bd 100%);
background: -moz-linear-gradient(top, #0077bb 0%, #0171bd 100%);
background: -webkit-linear-gradient(top, #0077bb 0%,#0171bd 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 10px;
list-style: none;
position: relative;
}
#nav > ul{display: table;}
.nav ul:after {
content: ""; clear: both; display: block;
}
.nav > ul > li {
display: table-cell;
}
.nav ul li:hover {
background: #bee6ff;
background: linear-gradient(top, #bee6ff 0%, #7dcdff 40%);
background: -moz-linear-gradient(top, #bee6ff 0%, #ffffff 50%);
background: -webkit-linear-gradient(top, #bee6ff 0%,#7dcdff 40%);
}
.nav ul li:hover a {
color: #363636;
}
.nav ul li a {
display: block; padding: 20px 12px;
color: #ffffff; text-decoration: none;
}
.nav ul ul {
background: #bee6ff;
background: linear-gradient(top, #bee6ff 0%, #7dcdff 40%);
background: -moz-linear-gradient(top, #bee6ff 0%, #ffffff 50%);
background: -webkit-linear-gradient(top, #bee6ff 0%,#7dcdff 40%);
border-radius: 0px;
padding: 0;
position: absolute; top: 100%;
}
.nav ul ul li {
float: none;
border-top: 1px solid #6cbdef;
border-bottom: 1px solid #6cbdef;
position: relative;
}
.nav ul ul li a {
padding: 15px 10px;
color: #fff;
}
.nav ul ul li a:hover {
background: #0075bb;
color:#FFF;
}
.nav ul ul ul {
position: absolute; left: 100%; top:0;
}
#media only screen
and (max-width : 992px) {
/* Styles */
.nav ul{
font-size: 12px;
padding: 0 5px;
}
.nav > ul > li > a{
padding: 10px 5px !important;
}
<div class="container">
<div class="nav">
<ul>
<li>
Home</li>
<li>
Site Settings
<ul>
<li>Add Meta Tags</li>
<li>Add Page Title</li>
</ul>
</li>
<li>User Managment</li>
<li>
Upload Images
<ul>
<li>Upload Slider Image</li>
<li>Upload Ads Image</li>
</ul>
</li>
<li>Content Managment</li>
<li>
Devotees
<ul>
<li>Add Devotee</li>
<li>Edit Devotee</li>
</ul>
</li>
<li>
News
<ul>
<li>Add News</li>
<li>Edit News</li>
</ul>
</li>
<li>
Donation
<ul>
<li>View Request</li>
<li>Approve Request</li>
</ul>
</li>
<li>
Blogs
<ul>
<li>Add Blog</li>
<li>Edit Blog</li>
</ul>
</li>
</ul>
</div>
</div>
you can decrease font-size for lower version using media queries.

expand the whole div along with the sub menu items when hover on the menu list

i have kept my menu bar in the div...when i scroll on the menu items the list appears..but i want the whole div to move expand along with the sub menus list....please can any one help...
this is my complete code..
*<doctype! html>
<html>
<head>
<style>
nav ul ul {
display: none;
}
nav ul li:hover > ul {
display: block;
}
nav ul {
background: #efefef;
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%);
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%);
box-shadow: 0px 0px 9px rgba(0,0,0,0.15);
padding: 0 20px;
border-radius: 10px;
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 {
background: #4b545f;
}
nav ul li:hover a {
color: #fff;
}
nav ul li a {
display: block; padding: 25px 40px;
color: #757575; text-decoration: none;
}
nav ul ul {
background: #5f6975; border-radius: 0px; padding: 0;
position: absolute; top: 100%;
}
nav ul ul li {
float: none;
border-top: 1px solid #6b727c;
border-bottom: 1px solid #575f6a;
position: relative;
}
nav ul ul li a {
padding: 15px 40px;
color: #fff;
}
nav ul ul li a:hover {
background: #4b545f;
}
</style>
</head>
<body>
<div style="width:100%;background:blue;">
<nav>
<ul>
<li>Home</li>
<li>Tutorials
<ul>
<li>Photoshop</li>
<li>Illustrator</li>
<li>Web Design
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
</ul>
</li>
<li>Articles
<ul>
<li>Web Design</li>
<li>User Experience</li>
</ul>
</li>
<li>Inspiration</li>
</ul>
</nav>
</div>
</body>
</html>*
I think you can make sure the length of the sub-menu is the same as the main menu label by forcing a fixed width on the main menu label like so:
nav ul li { width: 170px; }
I have created a live snippet here. However, note that doing this will cause the longer labels to be tucked to the second line.