I am having trouble with this navbar: https://jsfiddle.net/d6a7b3Ly/1/
1- With many links in the bar, the on-hover effect makes the other below links to move to the sides, but I am not sure which padding effect is doing that and how to fix it.
When changing border-top to 0px it fixes the issue, but makes the submenus not working:
#nav .current a, #nav li:hover > a {
background: #d1d1d1; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ebebeb', endColorstr='#a1a1a1'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#a1a1a1)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ebebeb, #a1a1a1); /* for firefox 3.6+ */
color: #444;
border-top: solid 1px #f8f8f8;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
2- I am trying to make a right to left option of the menu. and I changed float: right; under #nav li { in the csss, and added the whole html in a <div dir="RTL">, but the level 2 submenus are still opening facing left, and they should be right. I tested some changes in the css but none worked for that.
Here is a link to the rtl navbar: https://jsfiddle.net/ct8kp6eo/1/
And this is the floating change in the CSS:
#nav li {
margin: 0 5px;
padding: 0 0 8px;
float: right;
position: relative;
list-style: none;
}
To solve issue add padding-top: 7px to adjust for the border-top spoiling the layout to #nav ul li:hover a, #nav li:hover li a.
You have overlapping labels and to solve that adjust the z-index property of the #nav li:hover > ul to 1.
body {
font: normal .8em/1.5em Arial, Helvetica, sans-serif;
background: #ebebeb;
width: 900px;
margin: 100px auto;
color: #666;
}
a {
color: #333;
}
#nav {
margin: 0;
padding: 7px 6px 0;
line-height: 100%;
border-radius: 2em;
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
background: #8b8b8b; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#a9a9a9', endColorstr='#7a7a7a'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#a9a9a9), to(#7a7a7a)); /* for webkit browsers */
background: -moz-linear-gradient(top, #a9a9a9, #7a7a7a); /* for firefox 3.6+ */
border: solid 1px #6d6d6d;
}
#nav li {
margin: 0 5px;
padding: 0 0 8px;
float: left;
position: relative;
list-style: none;
}
/* main level link */
#nav a {
font-weight: bold;
color: #e7e5e5;
text-decoration: none;
display: block;
padding: 8px 20px;
margin: 0;
-webkit-border-radius: 1.6em;
-moz-border-radius: 1.6em;
text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
/* main level link hover */
#nav .current a, #nav li:hover > a {
background: #d1d1d1; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ebebeb', endColorstr='#a1a1a1'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#a1a1a1)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ebebeb, #a1a1a1); /* for firefox 3.6+ */
color: #444;
border-top: solid 1px #f8f8f8;
padding-top: 7px; /* ADDED */
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
/* sub levels link hover */
#nav ul li:hover a, #nav li:hover li a {
background: none;
border: none;
color: #666;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#nav ul a:hover {
background: #0399d4 !important; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#04acec', endColorstr='#0186ba'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba)) !important; /* for webkit browsers */
background: -moz-linear-gradient(top, #04acec, #0186ba) !important; /* for firefox 3.6+ */
color: #fff !important;
-webkit-border-radius: 0;
-moz-border-radius: 0;
text-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}
/* level 2 list */
#nav ul {
background: #ddd; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#cfcfcf'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#cfcfcf)); /* for webkit browsers */
background: -moz-linear-gradient(top, #fff, #cfcfcf); /* for firefox 3.6+ */
display: none;
margin: 0;
padding: 0;
width: 185px;
position: absolute;
top: 35px;
left: 0;
border: solid 1px #b4b4b4;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
/* dropdown */
#nav li:hover > ul {
display: block;
z-index: 1; /* ADDED */
}
#nav ul li {
float: none;
margin: 0;
padding: 0;
}
#nav ul a {
font-weight: normal;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
}
/* level 3+ list */
#nav ul ul {
left: 181px;
top: -3px;
}
/* rounded corners for first and last child */
#nav ul li:first-child > a {
-webkit-border-top-left-radius: 9px;
-moz-border-radius-topleft: 9px;
-webkit-border-top-right-radius: 9px;
-moz-border-radius-topright: 9px;
}
#nav ul li:last-child > a {
-webkit-border-bottom-left-radius: 9px;
-moz-border-radius-bottomleft: 9px;
-webkit-border-bottom-right-radius: 9px;
-moz-border-radius-bottomright: 9px;
}
/* clearfix */
#nav:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#nav {
display: inline-block;
}
html[xmlns] #nav {
display: block;
}
* html #nav {
height: 1%;
}
<ul id="nav">
<li class="current">Home</li>
<li>My Projects
<ul>
<li>N.Design Studio
<ul>
<li>Portfolio</li>
<li>WordPress Themes</li>
<li>Wallpapers</li>
<li>Illustrator Tutorials</li>
</ul>
</li>
<li>Web Designer Wall
<ul>
<li>Design Job Wall</li>
</ul>
</li>
<li>IconDock</li>
<li>Best Web Gallery</li>
</ul>
</li>
<li>Multi-Levels
<ul>
<li>Team
<ul>
<li>Sub-Level Item</li>
<li>Sub-Level Item
<ul>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
</ul>
</li>
<li>Sub-Level Item</li>
</ul>
</li>
<li>Sales</li>
<li>Another Link</li>
<li>Department
<ul>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
</ul>
</li>
</ul>
</li>
<li>About</li>
<li>Contact Us</li>
<li>Contact Us</li>
<li>Contact Us</li>
<li>Contact Us</li>
<li>Contact Us</li>
<li>Contact Us</li>
<li>Contact Us</li>
<li>Contact Us</li>
</ul>
To solve the second issue, add transform: translateX(-100%); to the #nav ul ul rule instead of the left value - see demo below:
body {
font: normal .8em/1.5em Arial, Helvetica, sans-serif;
background: #ebebeb;
margin: 100px auto;
color: #666;
}
a {
color: #333;
}
#nav {
margin: 0;
padding: 7px 6px 0;
line-height: 100%;
border-radius: 2em;
-webkit-border-radius: 2em;
-moz-border-radius: 2em;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
background: #8b8b8b; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#a9a9a9', endColorstr='#7a7a7a'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#a9a9a9), to(#7a7a7a)); /* for webkit browsers */
background: -moz-linear-gradient(top, #a9a9a9, #7a7a7a); /* for firefox 3.6+ */
border: solid 1px #6d6d6d;
}
#nav li {
margin: 0 5px;
padding: 0 0 8px;
float: right;
position: relative;
list-style: none;
}
/* main level link */
#nav a {
font-weight: bold;
color: #e7e5e5;
text-decoration: none;
display: block;
padding: 8px 4px;
margin: 0;
-webkit-border-radius: 1.6em;
-moz-border-radius: 1.6em;
text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
/* main level link hover */
#nav .current a, #nav li:hover > a {
background: #d1d1d1; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ebebeb', endColorstr='#a1a1a1'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#a1a1a1)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ebebeb, #a1a1a1); /* for firefox 3.6+ */
color: #444;
border-top: solid 1px #f8f8f8;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
/* sub levels link hover */
#nav ul li:hover a, #nav li:hover li a {
background: none;
border: none;
color: #666;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#nav ul a:hover {
background: #0399d4 !important; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#04acec', endColorstr='#0186ba'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba)) !important; /* for webkit browsers */
background: -moz-linear-gradient(top, #04acec, #0186ba) !important; /* for firefox 3.6+ */
color: #fff !important;
-webkit-border-radius: 0;
-moz-border-radius: 0;
text-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}
/* level 2 list */
#nav ul {
background: #ddd; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#cfcfcf'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#cfcfcf)); /* for webkit browsers */
background: -moz-linear-gradient(top, #fff, #cfcfcf); /* for firefox 3.6+ */
display: none;
margin: 0;
padding: 0;
width: 185px;
position: absolute;
top: 35px;
left: 10px
border: solid 1px #b4b4b4;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
/* dropdown */
#nav li:hover > ul {
display: block;
}
#nav ul li {
float: none;
margin: 0;
padding: 0;
}
#nav ul a {
font-weight: normal;
text-shadow: 0 1px 1px rgba(255, 255, 255, .9);
}
/* level 3+ list */
#nav ul ul {
/*left: 181px;*/
top: -3px;
transform: translateX(-100%);
}
/* rounded corners for first and last child */
#nav ul li:first-child > a {
-webkit-border-top-left-radius: 9px;
-moz-border-radius-topleft: 9px;
-webkit-border-top-right-radius: 9px;
-moz-border-radius-topright: 9px;
}
#nav ul li:last-child > a {
-webkit-border-bottom-left-radius: 9px;
-moz-border-radius-bottomleft: 9px;
-webkit-border-bottom-right-radius: 9px;
-moz-border-radius-bottomright: 9px;
}
/* clearfix */
#nav:after {
content: ".";
display: block;
clear: both;
visibility: hidden;
line-height: 0;
height: 0;
}
#nav {
display: inline-block;
}
html[xmlns] #nav {
display: block;
}
* html #nav {
height: 1%;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "#">
<body>
<div dir="RTL">
<ul id="nav" >
<li class="current" >Home</li>
<li>test
<ul>
<li>test >
<ul>
<li>test 2</li>
<li>test 3</li>
<li>test test test test test 4</li>
<li>test 555 Tutorials</li>
</ul>
<li>test
<ul>
<li>Design Job Wall</li>
</ul>
</li>
<li>IconDock</li>
<li>Best Web Gallery</li>
</ul>
</li>
<li>Multi-Levels
<ul>
<li>Team
<ul>
<li>Sub-Level Item</li>
<li>Sub-Level Item
<ul>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
</ul>
</li>
<li>Sub-Level Item</li>
</ul>
</li>
<li>Sales</li>
<li>Another Link</li>
<li>Department
<ul>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
<li>Sub-Level Item</li>
</ul>
</li>
</ul>
</li>
<li>About</li>
<li>Contact Us</li>
</ul>
</div>
You are adding a border-top solid 1px on hover. Change it to 0px on hover and it will work fine.
#nav .current a, #nav li:hover > a {
background: #d1d1d1; /* for non-css3 browsers */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ebebeb', endColorstr='#a1a1a1'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#ebebeb), to(#a1a1a1)); /* for webkit browsers */
background: -moz-linear-gradient(top, #ebebeb, #a1a1a1); /* for firefox 3.6+ */
color: #444;
/*border-top: solid 1px #f8f8f8;*/
border-top: solid 0px #f8f8f8;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}
adding 1px top on the hover just gets too much, which makes your items move
Related
Interesting title I know, didn't know how else to word it. I'm trying to have my navigation bar items evenly spaced regardless of font type which will change the size slightly. I've included a :hover feature with will darken the background behind the items. This works well, however when I add margins or padding to the left and right of nav ul to indent the sides, the darkened area is omitted from the margin/padding space.
The first is how it looks with no 'nav ul' padding. The second is with it where the area is cut off and the third is how I'd like it to look (with the 'home' text more centered, this was a rough mspaint edit lol.
On top of this, is there a way to make the padding for the 'header nav ul li a {' align perfectly so there's no space inbetween? I have a few px's space between where the hover occurs to allow for change in font-type without ruining the even spacing.
Totally a beginner at both CSS and HTML so if you're going to help me please only offer your kindest beginner-friendly advice.
JSFiddle: https://jsfiddle.net/c1y9axqt/
Relevant code:
CSS
.container {
width: 960px;
padding: 0 10px;
margin: 0 auto;
}
.nav_menu {
background-color: #005073;
background-image: -webkit-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Safari 5.1 to 6.0 */
background-image: -o-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Opera 11.1 to 12.0 */
background-image: -moz-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Firefox 3.6 to 15 */
background-image: linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* Standard syntax */
-webkit-box-shadow: inset 0px 0px 2px 1px rgba(0,0,0,0.4); /* For Firefox 3.6 to 15 */
-moz-box-shadow: inset 0px 0px 2px 1px rgba(0,0,0,0.4); /* For Firefox 3.6 to 15 */
box-shadow: inset 0px 0px 2px 1x rgba(0,0,0,0.4); /* Standard syntax */
border-style: solid;
border-width: 1px;
border-color: black;
height: 26px;
}
nav ul {
margin: 0;
padding: 0;
display: flex;
justify-content:space-between;
}
nav ul li{
display: inline;
}
header nav ul li a {
display: inline;
padding: 6px 30px 6px 30px;
letter-spacing: 1px;
text-decoration: none;
font-weight: bold;
line-height: 26px;
color: #EBEAEA;
text-shadow:
-1px -1px 1px rgba(0, 0, 0, .6),
1px -1px 1px rgba(0, 0, 0, .6),
-1px 1px 1px rgba(0, 0, 0, .6),
1px 1px 1px rgba(0, 0, 0, .6);
}
header nav ul li a:hover {
color: #E1E0E0;
background: rgba(0,0,0,0.2);
}
header nav ul li a:active {
-webkit-box-shadow: 0 0 5px rgba(0,0,0,0.7) inset;
-moz-box-shadow: 0 0 5px rgba(0,0,0,0.7) inset;
box-shadow: 0 0 5px rgba(0,0,0,0.7) inset;
color: #CECCCC;
background: rgba(0,0,0,0.3);
}
HTML
<header>
<div class="container clearfix">
<div class="nav_menu">
<nav>
<ul>
<li>Home</li>
<li>Website Design</li>
<li>Art & Poetry</li>
<li>Blog & Other</li>
<li>Music & More</li>
<li>Shop</li>
</ul>
</nav>
</div> <!-- end of container-->
</div> <!-- end of navigator menu bar-->
</header>
JSFiddle (again lol): https://jsfiddle.net/c1y9axqt/
guess you wanted this i changed only the css thats all
.container {
width: 960px;
padding: 0 10px;
margin: 0 auto;
}
.nav_menu {
background-color: #005073;
background-image: -webkit-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Safari 5.1 to 6.0 */
background-image: -o-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Opera 11.1 to 12.0 */
background-image: -moz-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Firefox 3.6 to 15 */
background-image: linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* Standard syntax */
-webkit-box-shadow: inset 0px 0px 2px 1px rgba(0,0,0,0.4); /* For Firefox 3.6 to 15 */
-moz-box-shadow: inset 0px 0px 2px 1px rgba(0,0,0,0.4); /* For Firefox 3.6 to 15 */
box-shadow: inset 0px 0px 2px 1x rgba(0,0,0,0.4); /* Standard syntax */
border-style: solid;
border-width: 1px;
border-color: black;
height: 26px;
}
header nav ul li:hover {
color: #E1E0E0;
background: rgba(0,0,0,0.2);
}
nav ul {
margin: 0;
padding: 0;
display: flex;
justify-content:space-between;
}
nav ul li{
display: inline;
width:160px;
text-align:center;
}
header nav ul li a {
display: inline;
letter-spacing: 1px;
text-decoration: none;
font-weight: bold;
line-height: 26px;
color: #EBEAEA;
text-shadow:
-1px -1px 1px rgba(0, 0, 0, .6),
1px -1px 1px rgba(0, 0, 0, .6),
-1px 1px 1px rgba(0, 0, 0, .6),
1px 1px 1px rgba(0, 0, 0, .6);
}
header nav ul li a:hover {
color: #E1E0E0;
background: rgba(0,0,0,0.2);
}
header nav ul li a:active {
-webkit-box-shadow: 0 0 5px rgba(0,0,0,0.7) inset;
-moz-box-shadow: 0 0 5px rgba(0,0,0,0.7) inset;
box-shadow: 0 0 5px rgba(0,0,0,0.7) inset;
color: #CECCCC;
background: rgba(0,0,0,0.3);
}
hope it helps
I've changed the way you had it styled slightly to keep things in blocks. I think you'd over complicated it for yourself in places.
As you can see i've set a width on the list items in the nav using % to keep them all evenly sized, and given them text-align: center;. Then by setting the background color of the anchor tags, it makes changing the color for the hover effect much easier.
You should look into Media Queries to make the nav become responsive for smaller screens.
Hope this all help,
Happy Coding!
Fiddle here
HTML:
<div id="navContainer">
<nav>
<ul>
<li>Home</li>
<li>Website Design</li>
<li>Art & Poetry</li>
<li>Blog & Other</li>
<li>Music & More</li>
<li>Shop</li>
</ul>
</nav>
</div>
CSS:
body {
margin: 0px 0px;
}
#navContainer {
width: 100%;
}
#navContainer nav {
width: 960px;
margin-left: auto;
margin-right: auto;
}
#navContainer ul {
list-style: none;
list-style-type: none;
padding: 0px 0px;
margin: 0px 0px;
}
#navContainer li {
float: left;
width: 16.666667%;
text-align: center;
}
#navContainer a {
text-decoration: none;
display: block;
background-color: #005073;
line-height: 26px;
}
#navContainer a {
text-decoration: none;
display: block;
background-color: #005073;
line-height: 26px;
color: #EBEAEA;
text-shadow:
-1px -1px 1px rgba(0, 0, 0, .6),
1px -1px 1px rgba(0, 0, 0, .6),
-1px 1px 1px rgba(0, 0, 0, .6),
1px 1px 1px rgba(0, 0, 0, .6);
font-weight: bold;
letter-spacing: 1px;
background-image: -webkit-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Safari 5.1 to 6.0 */
background-image: -o-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Opera 11.1 to 12.0 */
background-image: -moz-linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* For Firefox 3.6 to 15 */
background-image: linear-gradient(rgba(0,0,0,.3), rgba(125,125,125,.3)); /* Standard syntax */
}
#navContainer a:hover {
color: #E1E0E0;
background-image: -webkit-linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* For Safari 5.1 to 6.0 */
background-image: -o-linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* For Opera 11.1 to 12.0 */
background-image: -moz-linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* For Firefox 3.6 to 15 */
background-image: linear-gradient(rgba(0,0,0,.3), rgba(0,0,0,.2)); /* Standard syntax */
}
I'm using this:
jsfiddle.net/wromLbq5
And am hoping to have the ability to have multiple accordion sections open at once, and on page load. By this I mean, when one opens, I don't want the other to close. Is this possible? Without javascript as well.
(Ignore all the sub accordions too- I only need one layer)
HTML
<ul class="accordion">
<li id="one" class="files">
My Files<span>495</span>
<ul class="sub-menu">
<li><em>01</em>Dropbox<span>42</span></li>
<li><em>02</em>Skydrive<span>87</span></li>
<li><em>03</em>FTP Server<span>366</span></li>
<li><em>01</em>Dropbox<span>42</span></li>
<li><em>01</em>Dropbox<span>42</span></li>
</ul>
</li>
<li id="two" class="mail">
Mail<span>26</span>
<ul class="sub-menu">
<li><em>01</em>Hotmail<span>9</span></li>
<li><em>02</em>Yahoo<span>14</span></li>
<li><em>03</em>Gmail<span>3</span></li>
</ul>
</li>
<li id="three" class="cloud">
Cloud<span>58</span>
<ul class="sub-menu">
<li><em>01</em>Connect<span>12</span></li>
<li><em>02</em>Profiles<span>19</span></li>
<li><em>03</em>Options<span>27</span></li>
</ul>
</li>
<li id="four" class="sign">
Sign Out
<ul class="sub-menu">
<li><em>01</em>Log Out</li>
<li><em>02</em>Delete Account</li>
<li><em>03</em>Freeze Account</li>
</ul>
</li>
</ul>
CSS
body {margin:50px;}
/* Reset */
.accordion,
.accordion ul,
.accordion li,
.accordion a,
.accordion span {
margin: 0;
padding: 0;
border: none;
outline: none;
}
.accordion li {
list-style: none;
}
/* Layout & Style */
.accordion li > a {
display: block;
position: relative;
min-width: 110px;
padding: 0 10px 0 40px;
height: 32px;
color: #fdfdfd;
font: bold 12px/32px Arial, sans-serif;
text-decoration: none;
text-shadow: 0px 1px 0px rgba(0,0,0, .35);
background: #6c6e74;
background: -moz-linear-gradient(top, #6c6e74 0%, #4b4d51 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6c6e74), color-stop(100%,#4b4d51));
background: -webkit-linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
background: -o-linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
background: -ms-linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
background: linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
-webkit-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
-moz-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
}
.accordion > li:hover > a,
.accordion > li:target > a {
color: #3e5706;
text-shadow: 1px 1px 1px rgba(255,255,255, .2);
/*background: url(../img/active.png) repeat-x;*/
background: #a5cd4e;
background: -moz-linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a5cd4e), color-stop(100%,#6b8f1a));
background: -webkit-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: -o-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: -ms-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
}
.accordion li > a span {
display: block;
position: absolute;
top: 7px;
right: 0;
padding: 0 10px;
margin-right: 10px;
font: normal bold 12px/18px Arial, sans-serif;
background: #404247;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-box-shadow: inset 1px 1px 1px rgba(0,0,0, .2), 1px 1px 1px rgba(255,255,255, .1);
-moz-box-shadow: inset 1px 1px 1px rgba(0,0,0, .2), 1px 1px 1px rgba(255,255,255, .1);
box-shadow: inset 1px 1px 1px rgba(0,0,0, .2), 1px 1px 1px rgba(255,255,255, .1);
}
.accordion > li:hover > a span,
.accordion > li:target > a span {
color: #fdfdfd;
text-shadow: 0px 1px 0px rgba(0,0,0, .35);
background: #3e5706;
}
/* Images */
.accordion > li > a:before {
position: absolute;
top: 0;
left: 0;
content: '';
width: 24px;
height: 24px;
margin: 4px 8px;
background-repeat: no-repeat;
background-image: url(http://designmodo.com/demo/css3accordionmenu/img/icons.png);
background-position: 0px 0px;
}
.accordion li.files > a:before { background-position: 0px 0px; }
.accordion li.files:hover > a:before,
.accordion li.files:target > a:before { background-position: 0px -24px; }
.accordion li.mail > a:before { background-position: -24px 0px; }
.accordion li.mail:hover > a:before,
.accordion li.mail:target > a:before { background-position: -24px -24px; }
.accordion li.cloud > a:before { background-position: -48px 0px; }
.accordion li.cloud:hover > a:before,
.accordion li.cloud:target > a:before { background-position: -48px -24px; }
.accordion li.sign > a:before { background-position: -72px 0px; }
.accordion li.sign:hover > a:before,
.accordion li.sign:target > a:before { background-position: -72px -24px; }
/* Sub Menu */
.sub-menu li a {
color: #797979;
text-shadow: 1px 1px 0px rgba(255,255,255, .2);
background: #e5e5e5;
border-bottom: 1px solid #c9c9c9;
-webkit-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
-moz-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
}
.sub-menu li:hover a { background: #efefef; }
.sub-menu li:last-child a { border: none; }
.sub-menu li > a span {
color: #797979;
text-shadow: 1px 1px 0px rgba(255,255,255, .2);
background: transparent;
border: 1px solid #c9c9c9;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.sub-menu em {
position: absolute;
top: 0;
left: 0;
margin-left: 14px;
color: #a6a6a6;
font: normal 10px/32px Arial, sans-serif;
}
/* Functionality */
.accordion li > .sub-menu li {
height: 0;
overflow: hidden;
-webkit-transition: height .2s ease-in-out;
-moz-transition: height .2s ease-in-out;
-o-transition: height .2s ease-in-out;
-ms-transition: height .2s ease-in-out;
transition: height .2s ease-in-out;
}
.accordion li:target > .sub-menu li {
height: 33px;
}
I'm trying to avoid any java script.
Is this possible?
No this is not possible with only css, because your example uses the CSS3 :target selector. When you click on another item the target changes.
You cannot set state with css but you can style it. If you would like to keep each section open after clicking you would have to use javascript, but you don't need jQuery
If you would like to use javascript, this mimics the css as closely as possible while allowing the accordions to stay open. To close the accordion simply click on the title again.
var lists = document.querySelectorAll('.accordion > li > a'); // get list title links
for (var i = 0; i < lists.length; i++) { // for each list title link
lists[i].href = "javascript:void()"; // stop the page from jumping
lists[i].onclick = function(e) { // when you click the link
var items = e.target.parentNode.querySelectorAll('li'); // get all list items that are siblings of the clicked link
for (var x = 0; x < items.length; x++) { // for each list item
if (items[x].style.height != '33px') { // if its not open
items[x].style.height = '33px'; // open it
} else { // otherwise
items[x].style.height = '0px'; // close it
}
}
};
}
Wrap this in a script tag then either drop it in at the bottom of the body, or wrap it in document.onload = function() { /* Script Here */ }
(Demo)
Note while any style with the :target selector will cease to have effect, you should leave them in the css as a fallback in case the user has javascript disabled.
This css is showing all of the accordions as closed using this style:
.accordion li > .sub-menu li {
height: 0px;
}
You could set it to 33px to show all open when the page opens - but that would break the functionality as it is the :target selector which then sets the height and thus causes the selected section to show as open.
The only solution is to move into javascript.....
Can it be done? Yes
Do you need to change your HTML? Yes
Is it pretty? No
Basically instead of Target maintaining state. Use a checkbox replacing you top level a tags with label.
body {margin:50px;}
/* Reset */
.accordion,
.accordion ul,
.accordion li,
.accordion label,
.accordion span {
margin: 0;
padding: 0;
border: none;
outline: none;
}
.accordion li {
list-style: none;
}
.accordion input[type="checkbox"]{display:none;}
/* Layout & Style */
.accordion li > label, .accordion li > a {
display: block;
position: relative;
min-width: 110px;
padding: 0 10px 0 40px;
height: 32px;
color: #fdfdfd;
font: bold 12px/32px Arial, sans-serif;
text-decoration: none;
text-shadow: 0px 1px 0px rgba(0,0,0, .35);
background: #6c6e74;
background: -moz-linear-gradient(top, #6c6e74 0%, #4b4d51 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#6c6e74), color-stop(100%,#4b4d51));
background: -webkit-linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
background: -o-linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
background: -ms-linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
background: linear-gradient(top, #6c6e74 0%,#4b4d51 100%);
-webkit-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
-moz-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
}
.accordion > li:hover > label,
.accordion > li:target > label,
.accordion > li > input[type="checkbox"]:checked ~ label{
color: #3e5706;
text-shadow: 1px 1px 1px rgba(255,255,255, .2);
/*background: url(../img/active.png) repeat-x;*/
background: #a5cd4e;
background: -moz-linear-gradient(top, #a5cd4e 0%, #6b8f1a 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a5cd4e), color-stop(100%,#6b8f1a));
background: -webkit-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: -o-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: -ms-linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
background: linear-gradient(top, #a5cd4e 0%,#6b8f1a 100%);
}
.accordion li > label span, .accordion li > a span {
display: block;
position: absolute;
top: 7px;
right: 0;
padding: 0 10px;
margin-right: 10px;
font: normal bold 12px/18px Arial, sans-serif;
background: #404247;
-webkit-border-radius: 15px;
-moz-border-radius: 15px;
border-radius: 15px;
-webkit-box-shadow: inset 1px 1px 1px rgba(0,0,0, .2), 1px 1px 1px rgba(255,255,255, .1);
-moz-box-shadow: inset 1px 1px 1px rgba(0,0,0, .2), 1px 1px 1px rgba(255,255,255, .1);
box-shadow: inset 1px 1px 1px rgba(0,0,0, .2), 1px 1px 1px rgba(255,255,255, .1);
}
.accordion > li:hover > label span,
.accordion > li:target > label span,
.accordion > li > input[type="checkbox"]:checked ~ label span{
color: #fdfdfd;
text-shadow: 0px 1px 0px rgba(0,0,0, .35);
background: #3e5706;
}
/* Images */
.accordion > li > label:before {
position: absolute;
top: 0;
left: 0;
content: '';
width: 24px;
height: 24px;
margin: 4px 8px;
background-repeat: no-repeat;
background-image: url(http://designmodo.com/demo/css3accordionmenu/img/icons.png);
background-position: 0px 0px;
}
.accordion li.files > label:before { background-position: 0px 0px; }
.accordion li.files:hover > labe:before,
.accordion li.files:target > label:before { background-position: 0px -24px; }
.accordion li.mail > label:before { background-position: -24px 0px; }
.accordion li.mail:hover > label:before,
.accordion li.mail:target > label:before { background-position: -24px -24px; }
.accordion li.cloud > label:before { background-position: -48px 0px; }
.accordion li.cloud:hover > label:before,
.accordion input[type="checkbox"]:checked:before { background-position: -48px -24px; }
.accordion li.sign > label:before { background-position: -72px 0px; }
.accordion li.sign:hover > label:before,
.accordion input[type="checkbox"]:checked:before { background-position: -72px -24px; }
/* Sub Menu */
.sub-menu li > a {
color: #797979;
text-shadow: 1px 1px 0px rgba(255,255,255, .2);
background: #e5e5e5;
border-bottom: 1px solid #c9c9c9;
-webkit-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
-moz-box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
box-shadow: inset 0px 1px 0px 0px rgba(255,255,255, .1), 0px 1px 0px 0px rgba(0,0,0, .1);
}
.sub-menu li:hover a { background: #efefef; }
.sub-menu li:last-child a { border: none; }
.sub-menu li > a span {
color: #797979;
text-shadow: 1px 1px 0px rgba(255,255,255, .2);
background: transparent;
border: 1px solid #c9c9c9;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.sub-menu em {
position: absolute;
top: 0;
left: 0;
margin-left: 14px;
color: #a6a6a6;
font: normal 10px/32px Arial, sans-serif;
}
/* Functionality */
.accordion li > .sub-menu li {
height: 0;
overflow: hidden;
-webkit-transition: height .2s ease-in-out;
-moz-transition: height .2s ease-in-out;
-o-transition: height .2s ease-in-out;
-ms-transition: height .2s ease-in-out;
transition: height .2s ease-in-out;
}
.accordion input[type="checkbox"]:checked ~ .sub-menu li {
height: 33px;
}
<ul class="accordion">
<li id="one" class="files">
<input type="checkBox" id="cbOne" checked="checked" /><label for="cbOne" >My Files<span>495</span></label>
<ul class="sub-menu">
<li><em>01</em>Dropbox<span>42</span></li>
<li><em>02</em>Skydrive<span>87</span></li>
<li><em>03</em>FTP Server<span>366</span></li>
<li><em>01</em>Dropbox<span>42</span></li>
<li><em>01</em>Dropbox<span>42</span></li>
</ul>
</li>
<li id="two" class="mail">
<input type="checkBox" id="cbTwo" checked="checked" /><label for="cbTwo" >Mail<span>26</span></label>
<ul class="sub-menu">
<li><em>01</em>Hotmail<span>9</span></li>
<li><em>02</em>Yahoo<span>14</span></li>
<li><em>03</em>Gmail<span>3</span></li>
</ul>
</li>
<li id="three" class="cloud">
<input type="checkBox" id="cbThree" checked="checked" /><label for="cbThree" >Cloud<span>58</span></label>
<ul class="sub-menu">
<li><em>01</em>Connect<span>12</span></li>
<li><em>02</em>Profiles<span>19</span></li>
<li><em>03</em>Options<span>27</span></li>
</ul>
</li>
<li id="four" class="sign">
<input type="checkBox" id="cbFour" checked="checked" /><label for="cbFour" >Sign Out</label>
<ul class="sub-menu">
<li><em>01</em>Log Out</li>
<li><em>02</em>Delete Account</li>
<li><em>03</em>Freeze Account</li>
</ul>
</li>
</ul>
Look Ma! No Javascript!
I am developing a multiline menu in bootstrap and I have used a bootstrap css class “nav-justified” for width equality of every menu. The class “nav-justified” is working very well for equal width. But I need another option that is equal height, maintain height equality for every menu in that section. I added my problem with graphically in below:
nav.navbar {
width: 100%;
border: none;
margin: 0;
padding: 0;
background: #adadad;
border-bottom: 1px solid #8e8e8e
/*#8e8e8e*/
;
}
nav.navbar-fixed-top {
height: 150px;
position: fixed;
margin-left: 5px;
margin-right: 5px;
top: 26px;
bottom: 0;
right: 0;
left: 0;
float: none;
padding: 5px 5px 0px 5px;
background: #adadad;
/*mask-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #202020 25%, #202020 75%, rgba(255, 255, 255, 0) 100%);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
nav .container-fluid {
padding-right: 0px;
padding-left: 0px;
height: 100%;
}
.navbar-header .navbar-toggle .icon-bar {
background-color: black;
}
ul.top-menu {
/*width: 100%;*/
border: none;
margin: 0px 0px 0px 0px;
padding: 0;
/*height: 44px;*/
border-bottom: 1px solid #bbbbbb;
border-radius: 6px;
background: #5c5a5a;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#5c5a5a), to(#3d3b3b));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #3d3b3b, #5c5a5a);
/* IE 10 */
background: -ms-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #3d3b3b, #5c5a5a);
vertical-align: middle;
background: #353535;
/* Old browsers */
background: -moz-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #353535), color-stop(50%, #5c5a5a), color-stop(100%, #303030));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%);
/* IE10+ */
background: linear-gradient(to bottom, #353535 0%, #5c5a5a 50%, #303030 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#353535', endColorstr='#303030', GradientType=0);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
ul.top-menu > li.active {
background: #ff0000;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#6f0505), to(#ff0000));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #ff0000, #6f0505);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #ff0000, #6f0505);
/* IE 10 */
background: -ms-linear-gradient(top, #ff0000, #6f0505);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #ff0000, #6f0505);
outline: none;
}
ul.top-menu > li:last-child.active {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child.active {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.top-menu > li:hover {
cursor: pointer;
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
ul.top-menu > li:last-child:hover {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child:hover {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.sub-menu {
/*width: 100%;*/
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
}
ul.sub-menu > ul > li {
display: block;
/*width: 100%;*/
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
}
ul.sub-menu > li > ul > li > a {
text-align: left;
vertical-align: middle;
/*height: auto;*/
/*width: 100%;*/
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
text-shadow: 1px 1px 1px rgba(200, 200, 200, 0.9);
}
ul.sub-menu > li > ul > li > a:hover {
cursor: pointer;
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
color: #000;
}
ul.dropdown-menu {
margin-top: -2px;
/*position:relative;*/
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
li.dropdown:hover > ul.dropdown-menu {
display: block;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu > .dropdown-menu {
top: 0px;
left: 100%;
margin-top: -1px;
margin-left: -1px;
box-sizing: border-box;
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
}
.dropdown-submenu > a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-left-color: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover > a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left > .dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
.dropdown-menu > ul > ul {
border-radius: 0px;
width: 100%;
}
.dropdown-menu > li > a {
display: block;
padding: 5px 20px;
clear: both;
font-weight: normal;
line-height: 1.42857143;
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
width: 100%;
}
.dropdown-menu > li > a:hover {
background: #ff0000;
}
.dropdown-menu > li {
/*box-shadow:0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
border-bottom: 0.5px solid #d5d5d5;
border-top: 0.5px solid #f9f9f9;
border-radius: 0px;
min-width: 260px;
width: 100%;
background: #f2f2f2;
text-align: left;
}
.dropdown-menu > ul > li > a {
box-sizing: border-box;
border-radius: 0px;
width: 100%;
}
.dropdown-toggle > i {
text-align: right;
right: 10px;
position: absolute;
overflow: hidden;
line-height: 1.42857143;
}
.dropdown-menu > li.manage-bar {
background: #bbbbbb;
}
.dropdown-menu > li.manage-bar a {
color: #101010;
}
.dropdown-menu > li.report-bar {
background: #bbbbbb;
}
.dropdown-menu > li.report-bar a {
color: #101010;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="btn btn-primary navbar-toggle collapsed" data-toggle="collapse" data-target="#menu-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!--<a class="navbar-brand" href="#">Brand</a>-->
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menu-navbar-collapse-1">
<ul class="nav nav-justified top-menu">
<li class="active">
HOME
</li>
<li>
GARMENTS
</li>
<li>
YARN DYEING
</li>
<li>
KNITTING
</li>
<li>
FABRIC DYEING
</li>
<li>
COMMON MODULES
</li>
<li>
GENERAL SETTING
</li>
</ul>
<ul class="nav nav-justified">
<li>
<ul class="nav nav-justified" style="border: 1px solid #f00">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">ADMIN <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li>
Separated link
</li>
<li>
One more separated link
</li>
</ul>
</li>
</ul>
<ul class="nav nav-justified" style="border: 1px solid #f00">
<li>
HELP
</li>
</ul>
</li>
<li>
<ul class="nav nav-justified">
<li>
SUPPORT
</li>
</ul>
<ul class="nav nav-justified">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">CHAT <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
Action
</li>
<li>
Another action
</li>
<li>
Something else here
</li>
<li>
Separated link
</li>
<li>
One more separated link
</li>
</ul>
</li>
</ul>
</li>
<li>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
</li>
<li>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
<ul class="nav nav-justified">
<li>
NO MENU
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
EDIT==================================================
I have fixed this problem in plunker
But another problem is arising bootstrap dropdown popup does not come properly in IE, Like as below
I need this solution, this is working in chrome and mozila, whats the problem of me?
The complete solution is here
HTML CODE
html {
font-size: 10px;
position: relative;
min-height: 100%;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
html, body {
overflow-x: hidden;
height: 100%;
margin: 0;
}
body {
background: #efeff0 /*url('../img/background.jpg') no-repeat*/;
background-size: cover;
background-attachment: fixed;
/*font: 300 16px 'segoe', Helvetica, Arial, sans-serif;*/
background-color: #efeff0;
color: #303030;
font-family: segoe,"Helvetica Neue",Arial,sans-serif;
font-size: 14px;
line-height: 1.42857;
height: 100%;
width: 100%;
position: absolute;
/*border:5px solid #5f5f5f;*/
overflow: hidden;
}
/* Customize the nav-justified links to be fill the entire space of the .navbar */
.navbar-header .navbar-toggle .icon-bar {
background-color: black;
}
.nav-justified > li > a {
color: inherit;
}
.nav-justified > .active > a,
.nav-justified > .active > a:hover,
.nav-justified > .active > a:focus {
background-image: none;
background: none;
-webkit-box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
box-shadow: inset 0 3px 7px rgba(0,0,0,.15);
}
.nav-justified > li:first-child > a {
/*border-radius: 5px 5px 0 0;*/
}
.nav-justified > li:last-child > a {
/*border-bottom: 0;
border-radius: 0 0 5px 5px;*/
}
.nav-justified > li > a:hover {
background: none;
background-image: none;
}
.nav > li > a {
padding: 5px 10px 0px 20px;
}
#media (min-width: 768px) {
/*.nav-justified {
max-height: 52px;
}*/
.nav-justified > li > a {
border-right: 0.5px solid #404040;
border-left: 0.5px solid #353535;
color: #fff;
text-align: left;
}
.nav-justified > li:first-child > a {
border-left: 0;
border-radius: 6px 0 0 6px;
}
.nav-justified > li:last-child > a {
border-right: 0;
border-radius: 0 6px 6px 0;
}
}
.navbar-collapse {
border-top: 0px solid #4b4b4b;
/*padding:0px 5px 0px 5px;*/
}
/*.navbar-fixed-top .navbar-collapse, .navbar-static-top .navbar-collapse, .navbar-fixed-bottom .navbar-collapse {
padding: 5px 5px 0px 5px;
}*/
.container > .navbar-header, .container-fluid > .navbar-header, .container > .navbar-collapse, .container-fluid > .navbar-collapse {
margin: 0px 5px 0px 5px;
}
nav.navbar-fixed-top {
height: 150px;
position: fixed;
top: 26px;
bottom: 0;
right: 0;
left: 0;
float: none;
background: #adadad;
/*mask-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #202020 25%, #202020 75%, rgba(255, 255, 255, 0) 100%);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
.navbar-fixed-top, .navbar-fixed-bottom {
position: relative;
}
nav .container-fluid {
padding-right: 0px;
padding-left: 0px;
overflow: visible;
}
nav.navbar {
/*display: block;*/
width: 100%;
border: none;
margin: 0;
padding: 0;
background: #adadad;
border-bottom: 1px solid #8e8e8e /*#8e8e8e*/;
}
ul.top-menu {
width: 100%;
border: none;
margin: 5px 0px 0px 0px;
padding: 0;
min-height: 44px;
border-bottom: 1px solid #bbbbbb;
border-radius: 6px;
background: #5c5a5a;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#5c5a5a), to(#3d3b3b));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #3d3b3b, #5c5a5a);
/* IE 10 */
background: -ms-linear-gradient(top, #3d3b3b, #5c5a5a);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #3d3b3b, #5c5a5a); /*box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-moz-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-o-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-webkit-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-ms-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);*/
vertical-align: middle;
background: #353535; /* Old browsers */
background: -moz-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #353535), color-stop(50%, #5c5a5a), color-stop(100%, #303030)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #353535 0%, #5c5a5a 50%, #303030 100%); /* IE10+ */
background: linear-gradient(to bottom, #353535 0%, #5c5a5a 50%, #303030 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#353535', endColorstr='#303030', GradientType=0 ); /* IE6-9 */
/*background:url(NEXTIT.CK.GS.WebClient/Content/images/admin-logo.png) #fff;*/
/*mask-image: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, #202020 25%, #202020 75%, rgba(255, 255, 255, 0) 100%);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6); /*background:white;
background:rgba(255,255,255,0.8);*/
/*filter:blur(4px);
-o-filter:blur(4px);
-ms-filter:blur(4px);
-moz-filter:blur(4px);
-webkit-filter:blur(4px);*/
}
ul.top-menu > li > a {
color: #fff;
font-weight: normal;
}
ul.top-menu > li.active {
background: #ff0000;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#6f0505), to(#ff0000));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #ff0000, #6f0505);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #ff0000, #6f0505);
/* IE 10 */
background: -ms-linear-gradient(top, #ff0000, #6f0505);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #ff0000, #6f0505);
outline: none;
}
ul.top-menu > li:last-child.active {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child.active {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.top-menu > li:hover {
/*background-color: #f00;*/
/*border-radius:6px;*/
/*background:rgba(255, 255, 255, 0.2);*/
cursor: pointer;
/*background: -moz-linear-gradient(top, rgba(0,0,0,0.2) 0%, rgba(255,255,255,0.5) 50%, rgba(0,0,0,0.2) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.2)), color-stop(50%,rgba(255,255,255,0.2)), color-stop(100%,rgba(0,0,0,0.2)));
background: -webkit-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
background: -o-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
background: -ms-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
background: linear-gradient(to bottom, rgba(0,0,0,0.2) 0%,rgba(255,255,255,0.2) 50%,rgba(0,0,0,0.2) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#33000000', endColorstr='#33000000',GradientType=0 );
-webkit-box-shadow: inset 5px rgba(0,0,0,.2), 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 5px rgba(0,0,0,.2), 0 0 8px rgba(102, 175, 233, 0.6);*/
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
}
ul.top-menu > li:last-child:hover {
border-top-right-radius: 6px;
border-bottom-right-radius: 6px;
}
ul.top-menu > li:first-child:hover {
border-top-left-radius: 6px;
border-bottom-left-radius: 6px;
}
ul.sub-menu {
width: 100%;
height: 100px;
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
list-style: none;
display: block; /*box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-moz-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-o-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-webkit-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);
-ms-box-shadow: 2px 2px 2px rgba(0,0,0,0.40);*/
}
ul.sub-menu > li {
height: 100px;
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
list-style: none;
}
ul.sub-menu > li > div {
height: 100%;
display: table;
table-layout: fixed;
border-collapse: collapse;
width: 100%;
}
ul.sub-menu > li > div > ul {
display: table-row;
}
ul.sub-menu > li > div > ul > li {
display: table-cell;
width: 100%;
border: none;
margin: 0;
padding: 0;
vertical-align: middle;
padding-left: 20px;
height: auto;
}
ul.sub-menu > li > div > ul > li > a {
text-align: left;
text-decoration: none;
height: 100%;
line-height: 100%;
display: table;
content: "";
clear: both;
vertical-align: middle;
width: 100%;
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
text-shadow: 1px 1px 1px rgba(200,200,200,0.9);
padding: 0px;
}
ul.sub-menu > li > div > ul > li > a > span {
line-height: 100%;
display: table-cell;
vertical-align: middle;
clear: both;
}
ul.sub-menu > li > div > ul > li > a > span i {
float: right;
margin-right: 14px;
content: "";
clear: both;
/*margin-top: -18px;
right: 10px;
text-align: right;*/
}
ul.sub-menu > li > div > ul > li > a:hover {
background: none;
}
ul.sub-menu > li > div > ul > li:hover {
cursor: pointer;
background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 25%, rgba(255, 255, 255, 0.2) 75%, rgba(255, 255, 255, 0) 100%);
/*-webkit-box-shadow:0px 1px 1px rgba(0, 0, 0, 0.1);
-moz-box-shadow:0px 1px 1px rgba(0, 0, 0, 0.1);
box-shadow:0px 1px 1px rgba(0, 0, 0, 0.1);*/
box-shadow: 0 0 25px rgba(0, 0, 0, 0.1), inset 0 0 1px rgba(255, 255, 255, 0.6);
color: #000;
}
/*ul.sub-menu > li > div > ul > li.dropdown > ul.dropdown-menu {
top: 100%;
}*/
ul.dropdown-menu {
width: 100%;
margin: 0;
padding: 0;
}
li.dropdown:hover > ul.dropdown-menu {
display: block;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu > .dropdown-menu {
top: 0px;
left: 100%;
margin-top: -2px;
margin-left: -1px;
/*-webkit-border-radius: 0 6px 6px 6px;
-moz-border-radius: 0 6px 6px;
border-radius: 0 6px 6px 6px;*/
/*box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
}
.dropdown-submenu > .dropToLeft {
left: auto;
right: 100%;
top: 0px;
/*position:relative;*/
}
.dropdown-submenu:hover > .dropdown-menu {
display: block;
}
.dropdown-submenu > a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-left-color: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover > a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left > .dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
.dropdown-menu > ul > ul {
border-radius: 0px;
width: 100%;
}
.dropdown-menu > li > a {
display: block;
padding: 5px 20px;
clear: both;
font-weight: normal;
line-height: 1.42857143;
color: #101010;
font-size: 10pt;
white-space: nowrap;
text-transform: capitalize;
width: 100%;
}
.dropdown-menu > li > a:hover {
background: #ff0000;
}
.dropdown-menu > li:hover {
background: #ff0000;
}
.dropdown-menu > li {
/*box-shadow:0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
border-bottom: 0.5px solid #d5d5d5;
border-top: 0.5px solid #f9f9f9;
border-radius: 0px;
width: 100%;
background: #f2f2f2;
text-align: left;
}
.dropdown-menu > ul > li > a {
/*box-shadow:0 1px 1px rgba(0, 0, 0, 0.1);*/
box-sizing: border-box;
/*border-bottom:1px solid rgba(0,0,0,0.40);
border-top:1px solid #ccc;*/
border-radius: 0px;
width: 100%;
}
.dropdown-toggle > i {
text-align: right;
right: 10px;
position: absolute;
overflow: hidden;
line-height: 1.42857143;
}
.dropdown-menu > li.manage-bar {
background: #bbbbbb;
}
.dropdown-menu > li.manage-bar a {
color: #101010;
}
.dropdown-menu > li.report-bar {
background: #bbbbbb;
}
.dropdown-menu > li.report-bar a {
color: #101010;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="author" content="" />
<script data-require="jquery#*" data-semver="2.1.1" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link data-require="bootstrap#*" data-semver="3.2.0" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.css" />
<script data-require="bootstrap#*" data-semver="3.2.0" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<nav class="navbar navbar-fixed-top" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!--<a class="navbar-brand" href="#">Brand</a>-->
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menu-navbar-collapse-1">
<ul class="top-menu nav nav-justified">
<li class="active">HOME</li>
<li>GARMENTS</li>
<li>YARN DYEING</li>
<li>KNITTING</li>
<li>FABRIC DYEING</li>
<li>COMMON MODULES</li>
<li>GENERAL SETTING</li>
</ul>
<ul class="sub-menu nav nav-justified">
<li>
<div>
<ul>
<li class="dropdown"><span>ADMIN <span class="caret"></span></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li class="dropdown-submenu"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Manage
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li><span>HELP</span></li>
</ul>
</div>
</li>
<li>
<div>
<ul>
<li><span>HELP</span></li>
</ul>
<ul>
<li class="dropdown"><span>CHAT<span class="caret"></span></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</div>
</li>
<li>
<div>
<ul>
<li><span>NO MENU</span></li>
</ul>
<ul>
<li><span>NO MENU</span></li>
</ul>
</div>
</li>
<li>
<div>
<ul>
<li><span>NO MENU</span></li>
</ul>
<ul>
<li class="dropdown"><span>ADMIN<span class="caret"></span></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li class="dropdown-submenu ">Manage <span class="caret"></span>
<ul class="dropdown-menu dropToLeft" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</body>
</html>
i have a menu with sub menu, that when its hover the <a> in the sub-menu is doesnt show the font, only it's shadow if you look closly. i have tried changing alot of code but nothing is working . here is the menu:http://jsfiddle.net/2fDQz/16/ ( sub menu on home and admin)
here is the css:(although you can see it in the jsfiddle)
body {
}
/* Base Styles */
#personalbar ul,
#personalbar li,
#personalbar a {
list-style: none;
margin: 0;
padding: 0;
border: 0;
line-height: 1;
font-family: 'Lato', sans-serif;
}
#personalbar {
border: 1px solid #123e3f;
width: auto;
}
#personalbar ul {
zoom: 1;
background: #33b3b7;
background: -moz-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #33b3b7), color-stop(100%, #288c8f));
background: -webkit-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -o-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -ms-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: linear-gradient(top, #33b3b7 0%, #288c8f 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#top-color', endColorstr='#bottom-color', GradientType=0);
padding: 5px 10px;
}
#personalbar ul:before {
content: '';
display: block;
}
#personalbar ul:after {
content: '';
display: table;
clear: both;
}
#personalbar li {
float: left;
margin: 0 5px 0 0;
border: 1px solid transparent;
position:relative;
}
#personalbar li a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
padding: 8px 15px 9px 15px;
display: block;
text-decoration: none;
color: #ffffff;
border: 1px solid transparent;
font-size: 16px;
}
#personalbar li.active {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
border: 1px solid #33b3b7;
}
#personalbar li.active a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
display: block;
background: #1d6567;
border: 1px solid #123e3f;
-moz-box-shadow: inset 0 5px 10px #123e3f;
-webkit-box-shadow: inset 0 5px 10px #123e3f;
box-shadow: inset 0 5px 10px #123e3f;
}
#personalbar li:hover {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
border: 1px solid #33b3b7;
}
#personalbar li:hover a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
display: block;
background: #1d6567;
border: 1px solid #123e3f;
-moz-box-shadow: inset 0 5px 10px #123e3f;
-webkit-box-shadow: inset 0 5px 10px #123e3f;
box-shadow: inset 0 5px 10px #123e3f;
}
#personalbar ul ul li:hover a ,
#personalbar li:hover li a
{
background: none;
border: none;
color: #666;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#personalbar ul ul a:hover
{
background: #7d7d7d;
color: #fff !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
#personalbar li:hover > ul {
display: block;
}
#personalbar ul ul
{
position:absolute;
z-index: 1000;
display: none;
margin: 0;
padding: 0;
min-width: 100%;
top: 35px;
left: 0;
background: #ffffff;
border: solid 1px #b4b4b4;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
#personalbar ul ul li {
position: relative;
float: none;
margin: 0;
padding: 3px;
}
html:
<div id='personalbar'style="position:absolute; top:0%;left:0%; width:100%;">
<ul>
<li><a href='# '><span>Home</span></a>
<ul>
<li id="Li2" runat="server"><a id="A5" href="#" runat="server"><span>blasdfgsfgsg</span></a></li>
<li id="Li3" runat="server"><a id="A6" href="#" runat="server"><span>bli</span></a></li>
</ul></li>
<li id="L1" runat="server"><a id="A1" href="../ClientSide/newsFeed/allEr.aspx" runat="server"><span>My Wall</span></a></li>
<li id="L2" runat="server"><a id="A2" href="../ClientSide/employee/eeSettings.aspx" runat="server"><span>Setting</span></a></li>
<li id="Li1" runat="server"><a id="A4" href="../ClientSide/employee/eeSettings.aspx" runat="server"><span>Admin</span></a>
<ul>
<li runat="server"><span>bla</span></li>
<li runat="server"><span>bli</span></li>
</ul>
</li>
<li id="L3" runat="server" style="position:absolute; right:1%;" ><a id="A3" href="../ClientSide/Registration/registration.aspx" runat="server"><span>Sign Up</span></a></li>
</ul>
</div>
Thanks fopr the Help :D
color: #000000 !important;
change your color in #personalbar ul ul a:hover{}
Fiddle
Remove
color: #fff !important;
is a white color. So, only you can't able to see the text...
In your:
#personalbar ul ul a:hover
{
background: #7d7d7d;
color: #fff !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
Change color to color: #000;
FIX
I have a menu, which every thing works except of the sub menu. when the <li> with the sub menu is hover its suppose to show a sub menu, and it does. but the problem is with the position of the sub menu, it doesn't show it under the <li> it shows it left: 0%.
http://jsfiddle.net/2fDQz/1/ - Try and put your mouse over the "admin" and the "home".
here is the css(although you can see it in the jsfiddle):
CSS
body {
}
/* Base Styles */
#personalbar ul, #personalbar li, #personalbar a {
list-style: none;
margin: 0;
padding: 0;
border: 0;
line-height: 1;
font-family:'Lato', sans-serif;
}
#personalbar {
border: 1px solid #123e3f;
width: auto;
}
#personalbar ul {
zoom: 1;
background: #33b3b7;
background: -moz-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #33b3b7), color-stop(100%, #288c8f));
background: -webkit-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -o-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -ms-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: linear-gradient(top, #33b3b7 0%, #288c8f 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#top-color', endColorstr='#bottom-color', GradientType=0);
padding: 5px 10px;
}
#personalbar ul:before {
content:'';
display: block;
}
#personalbar ul:after {
content:'';
display: table;
clear: both;
}
#personalbar li {
float: left;
margin: 0 5px 0 0;
border: 1px solid transparent;
}
#personalbar li a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
padding: 8px 15px 9px 15px;
display: block;
text-decoration: none;
color: #ffffff;
border: 1px solid transparent;
font-size: 16px;
}
#personalbar li.active {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
border: 1px solid #33b3b7;
}
#personalbar li.active a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
display: block;
background: #1d6567;
border: 1px solid #123e3f;
-moz-box-shadow: inset 0 5px 10px #123e3f;
-webkit-box-shadow: inset 0 5px 10px #123e3f;
box-shadow: inset 0 5px 10px #123e3f;
}
#personalbar li:hover {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
border: 1px solid #33b3b7;
}
#personalbar li:hover a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
display: block;
background: #1d6567;
border: 1px solid #123e3f;
-moz-box-shadow: inset 0 5px 10px #123e3f;
-webkit-box-shadow: inset 0 5px 10px #123e3f;
box-shadow: inset 0 5px 10px #123e3f;
}
#personalbar ul ul li:hover a, #personalbar li:hover li a {
background: none;
border: none;
color: #666;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#personalbar ul ul a:hover {
background: #7d7d7d;
color: #fff !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
#personalbar li:hover > ul {
display: block;
}
#personalbar ul ul {
position:absolute;
z-index: 1000;
display: none;
margin: 0;
padding: 0;
width: 185px;
top: 40px;
left: 0;
background: #ffffff;
border: solid 1px #b4b4b4;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
#personalbar ul ul li {
position: relative;
float: none;
margin: 0;
padding: 3px;
}
HTML:
<div id='personalbar' style="position:absolute; top:0%;left:0%; width:100%;">
<ul>
<li><a href='# '><span>Home</span></a>
<ul>
<li id="Li2" runat="server"><a id="A5" href="#" runat="server"><span>bla</span></a>
</li>
<li id="Li3" runat="server"><a id="A6" href="#" runat="server"><span>bli</span></a>
</li>
</ul>
</li>
<li id="L1" runat="server"><a id="A1" href="../ClientSide/newsFeed/allEr.aspx" runat="server"><span>My Wall</span></a>
</li>
<li id="L2" runat="server"><a id="A2" href="../ClientSide/employee/eeSettings.aspx" runat="server"><span>Setting</span></a>
</li>
<li id="Li1" runat="server"><a id="A4" href="../ClientSide/employee/eeSettings.aspx" runat="server"><span>Admin</span></a>
<ul>
<li runat="server"><span>bla</span>
</li>
<li runat="server"><span>bli</span>
</li>
</ul>
</li>
<li id="L3" runat="server" style="position:absolute; right:1%;"><a id="A3" href="../ClientSide/Registration/registration.aspx" runat="server"><span>Sign Up</span></a>
</li>
</ul>
</div>
I have tried changing the #personalbar ul ul 's position to relative, and here is what is did: http://jsfiddle.net/2fDQz/2/
You need to wrap absolute positioned element inside a position: relative; container...
Demo
#personalbar li {
float: left;
margin: 0 5px 0 0;
position: relative;
border: 1px solid transparent;
}
Note, as pointed by #Amarnath, in the above demo, the menu will collapse as soon you hover the child elements, it's because you are using top: 40px; so get rid of that - Demo
#personalbar ul ul {
position:absolute;
z-index: 1000;
display: none;
margin: 0;
padding: 0;
width: 185px;
top: 40px; /* Take this out from here */
left: 0;
background: #ffffff;
border: solid 1px #b4b4b4;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
Also, would like to suggest you, that when you deal with such a markup, it is better to use > selector so that the elements you select via CSS are precise.. If you are not aware of what does that selector do, it selects direct child of the element. For example using something like
ul li ul {
/* Selects all ul element nested under li */
}
Whereas using something like
ul > li > ul {
/* Selects direct ul element nested under li - First Level */
}
You need to set all the li's positions to relative for it to work. Making something position: relative resets the positioning values for any child elements. When using absolute positioning inside a relatively positioned parent, the child (when set to left: 0; top: 0; for example) will position itself to the top left edge of the parent and not the document. A good point to note as well is that the z-index property also resets relative to the parent.
Try this:
body {}
/* Base Styles */
#personalbar ul,
#personalbar li,
#personalbar a {
list-style: none;
margin: 0;
padding: 0;
border: 0;
line-height: 1;
font-family: 'Lato', sans-serif;
}
#personalbar {
border: 1px solid #123e3f;
width: auto;
}
#personalbar ul {
zoom: 1;
background: #33b3b7;
background: -moz-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #33b3b7), color-stop(100%, #288c8f));
background: -webkit-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -o-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: -ms-linear-gradient(top, #33b3b7 0%, #288c8f 100%);
background: linear-gradient(top, #33b3b7 0%, #288c8f 100%);
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#top-color', endColorstr='#bottom-color', GradientType=0);
padding: 5px 10px;
}
#personalbar ul:before {
content: '';
display: block;
}
#personalbar ul:after {
content: '';
display: table;
clear: both;
}
#personalbar li {
float: left;
margin: 0 5px 0 0;
border: 1px solid transparent;
position: relative; /* This is the important bit */
}
#personalbar li a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
padding: 8px 15px 9px 15px;
display: block;
text-decoration: none;
color: #ffffff;
border: 1px solid transparent;
font-size: 16px;
}
#personalbar li.active {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
border: 1px solid #33b3b7;
}
#personalbar li.active a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
display: block;
background: #1d6567;
border: 1px solid #123e3f;
-moz-box-shadow: inset 0 5px 10px #123e3f;
-webkit-box-shadow: inset 0 5px 10px #123e3f;
box-shadow: inset 0 5px 10px #123e3f;
}
#personalbar li:hover {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
border: 1px solid #33b3b7;
}
#personalbar li:hover a {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
display: block;
background: #1d6567;
border: 1px solid #123e3f;
-moz-box-shadow: inset 0 5px 10px #123e3f;
-webkit-box-shadow: inset 0 5px 10px #123e3f;
box-shadow: inset 0 5px 10px #123e3f;
}
#personalbar ul ul li:hover a,
#personalbar li:hover li a {
background: none;
border: none;
color: #666;
-webkit-box-shadow: none;
-moz-box-shadow: none;
}
#personalbar ul ul a:hover {
background: #7d7d7d;
color: #fff !important;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}
#personalbar li:hover > ul {
display: block;
}
#personalbar ul ul {
position: absolute;
z-index: 1000;
display: none;
margin: 0;
padding: 0;
top: 40px;
left: 0;
background: #ffffff;
border: solid 1px #b4b4b4;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
#personalbar ul ul li {
position: relative;
float: none;
margin: 0;
padding: 3px;
}
<div id='personalbar' style="position:absolute; top:0%;left:0%; width:100%;">
<ul>
<li><a href='# '><span>Home</span></a>
<ul>
<li id="Li2" runat="server"><a id="A5" href="#" runat="server"><span>bla</span></a>
</li>
<li id="Li3" runat="server"><a id="A6" href="#" runat="server"><span>bli</span></a>
</li>
</ul>
</li>
<li id="L1" runat="server"><a id="A1" href="../ClientSide/newsFeed/allEr.aspx" runat="server"><span>My Wall</span></a>
</li>
<li id="L2" runat="server"><a id="A2" href="../ClientSide/employee/eeSettings.aspx" runat="server"><span>Setting</span></a>
</li>
<li id="Li1" runat="server"><a id="A4" href="../ClientSide/employee/eeSettings.aspx" runat="server"><span>Admin</span></a>
<ul>
<li runat="server"><span>bla</span>
</li>
<li runat="server"><span>bli</span>
</li>
</ul>
</li>
<li id="L3" runat="server" style="position:absolute; right:1%;"><a id="A3" href="../ClientSide/Registration/registration.aspx" runat="server"><span>Sign Up</span></a>
</li>
</ul>
</div>