I'm coding a website for uni right now and it's going pretty well, with the exception of a dropdown menu issue. I've given the li property an ID of "selected" on some menu options (when the user is on the page in question), so that it changes colour to a dark pink.
However, the dropdown options underneath whatever has the li id of "selected" all turn dark pink too. When I add a closed li tag at the end of "about" in the html, the dropdown doesn't appear at all.
I'll post the relevant html and CSS as well as screenshots, hopefully someone could help me, please!
THIS is how a dropdown menu (without the id of "selected") looks normally. the links work and it goes slightly darker when i hover over, which is what i want
whereas THIS has the "selected" id. i don't want the dropdown menu this colour - JUST the "about" box
Here's all of the dropdown code:
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#ffeff8;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:"Luna";
text-transform: lowercase;
border:1px solid #ed85c4;
}
.menu a {
transition:all linear 0.15s;
color:#ed85c4;
background:#ffeff8;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#d771ae;
}
.menu .arrow {
font-size:10px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:14px;
}
.menu > ul > li > a {
padding:3px 40px;
display:inline-block;
text-shadow:0px 0px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > a {
background:#f1dae8;
}
.menu > ul > li#selected a{
color: #ffeff8;
background: #c864a1;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
}
.sub-menu {
width:100%;
padding:0px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 0px 0px rgba(0,0,0,0.2);
}
.sub-menu li {
display:block;
font-size:12px;
text-transform: lowercase;
font-kerning: auto;
}
.sub-menu li a {
padding:10px 30px;
display:block;
background: #ffeff8;
}
.sub-menu li a:hover, .sub-menu a {
background: #f1dae8;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li id="selected">
about <span class="arrow">▼</span>
<ul class="sub-menu">
<li>history</li>
<li>values</li>
<li>the truck</li>
<li>produce info.</li>
</ul>
</li>
You did not select correctly the link below the #selected list item.
.menu > ul > li#selected a /*This selects all links below the selected li, including links in child list items*/
should be
.menu > ul > li#selected > a /* this selects the immediate descendent link only */
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#ffeff8;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:"Luna";
text-transform: lowercase;
border:1px solid #ed85c4;
}
.menu a {
transition:all linear 0.15s;
color:#ed85c4;
background:#ffeff8;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#d771ae;
}
.menu .arrow {
font-size:10px;
line-height:0%;
}
/*----- Top Level -----*/
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:14px;
}
.menu > ul > li > a {
padding:3px 40px;
display:inline-block;
text-shadow:0px 0px 0px rgba(0,0,0,0.4);
}
.menu > ul > li:hover > a, .menu > ul > a {
background:#f1dae8;
}
.menu > ul > li#selected >a{
color: #ffeff8;
background: #c864a1;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
}
.sub-menu {
width:100%;
padding:0px 0px;
position:absolute;
top:100%;
left:0px;
z-index:-1;
opacity:0;
transition:opacity linear 0.15s;
box-shadow:0px 0px 0px rgba(0,0,0,0.2);
}
.sub-menu li {
display:block;
font-size:12px;
text-transform: lowercase;
font-kerning: auto;
}
.sub-menu li a {
padding:10px 30px;
display:block;
background: #ffeff8;
}
.sub-menu li a:hover, .sub-menu a {
background: #f1dae8;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li id="selected">
about <span class="arrow">▼</span>
<ul class="sub-menu">
<li>history</li>
<li>values</li>
<li>the truck</li>
<li>produce info.</li>
</ul>
</li>
Related
*
I don't know what I am doing wrong here so can you help me? I want to create a cascading drop-down menu and I can't see what I am doing wrong. I've tried everything. I am just out of ideas
*
HERE IS MY CODE
<style type="text/css">
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.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,
.menu li:hover .sub-menu1{
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-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a{
padding:10px 30px;
display:block;
}
.sub-menu1 li a{
padding:10px 10px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
}
</style>
</body>
</html>
<html>
<head>
<title> Australia </title>
</head>
<body>
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Sydney
<ul class="sub-menu1">
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
You can use adjacent sibling selector for more info visit this link On a CSS hover event, can I change another div's styling?
Set display:none initially to sub-menu1 class and on hover of sub-menu li a set display of adjacent sub-menu1 back to block.
Here is the code:
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.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,
.menu li:hover .sub-menu1{
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-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
display: none;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
display: block;
}
.sub-menu li a:hover + .sub-menu1{
display:block;
padding:10px 10px;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>Sydney
<ul class="sub-menu1">
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
Or you can have an indentation on your submenus? It really depends on what you want. Could you give some example? Here's what I meant when I was talking about indentation :
body {
background:#bf5c71 url('australia1.jpg');
}
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.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,
.menu li:hover .sub-menu1{
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-menu1 {
width:100%;
padding:0px 0px;
position:relative;
top:100%;
left:370px;
z-index:100;
opacity:50;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0,0,0,0.2);
background:#2e2758;
}
.sub-menu li,
.sub-menu1 li
{
display:block;
font-size:16px;
}
.sub-menu li a{
padding:10px 30px;
display:block;
}
.sub-menu1 li a{
padding:10px 10px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a
{
background:#3e3436;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li>
Sydney
<ul>
<li>Test
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
First of all,you must write 0 instead of 0px.
you must make the sub-menu1 display: none; then when mouse is on sydney the sub-menu must be display: block;
i have fixed somethings and this will be your code:
body {
background: #bf5c71;
}
.clearfix:after {
display: block;
clear: both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width: 100%;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
background: #3e3436;
}
.menu {
width: 1000px;
margin: 0 auto;
}
.menu li {
margin: 0;
list-style: none;
font-family: 'Ek Mukta';
}
.menu a {
transition: all linear 0.15s;
color: #919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration: none;
color: #be5b70;
}
.menu .arrow {
font-size: 11px;
line-height: 0;
}
/*----- Top Level -----*/
.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: 0 1px 0 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,
.menu li:hover .sub-menu1 {
z-index: 1;
opacity: 1;
}
.sub-menu {
width: 160%;
padding: 5px 0;
position: absolute;
top: 0;
left: 0;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2728;
}
#sydney:hover .sub-menu1 {
display: block;
}
.sub-menu1 {
width: 100%;
padding: 0;
position: relative;
top: 0;
left: 370px;
z-index: 100;
opacity: 50;
transition: opacity linear .15s;
box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
background: #2e2758;
display: none;
}
.sub-menu li,
.sub-menu1 li {
font-size: 16px;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
}
.sub-menu li a:hover, .sub-menu .current-item a,
.sub-menu1 li a:hover, .sub-menu1 .current-item a {
background: #3e3436;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Acasa</li>
<li>Obiective turistice<span class="arrow">▼</span>
<ul class="sub-menu">
<li id="sydney">Sydney
<ul class="sub-menu1">
<li>Test</li>
</ul>
</li>
<li>Melbourne</li>
<li>Brisbane</li>
<li>Perth</li>
</ul>
</li>
<li class="current-item">Galerie Foto</li>
<li>Video</li>
</ul>
</nav>
</div>
Im making a landing page for a job and doing the navbar then i figured it out that i have to set the navbar fixed to top, after i fixed it the collapse of the second bar is just showing up when im not even hover on it. Had to add more margin to the next item to work "propertly" but is kinda ugly
.fixed-top {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
top: 0;
border-width: 0 0 1px;
}
#nav ul li a {
display: block;
padding: 7px 15px;
text-decoration: none;
font-weight: bold;
color: #FFFFFF;
}
#nav li a:hover {
color: #000000;
background-color: #fff;
}
#nav .navbar-izquierda ul {
width: 100%;
float: left;
margin: auto;
padding: 0;
list-style: none;
background-color: #434343;
box-shadow: 10px 0 10px #000000;
border-bottom: 1px solid #000000;
}
.clearfix:after {
display:block;
clear:both;
}
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width: auto;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:14px;
}
.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;
}
/*----- DropDown Navbar Inferior -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
}
.sub-menu {
width:100%;
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:inline-block;
}
.sub-menu li a:hover, .sub-menu .current-item a {
background:#3e3436;
}
<div class="navbar-izquierda menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li class="active">Portatil</li>
<li>Desk</li>
<li>Workstation</li>
<li>Promotions</li>
<li>Services and Guarantees <span class="arrow">▼</span>
<ul class="sub-menu">
<li>Error 1</li>
<li>Error 2</li>
<li>Horror 3</li>
</ul>
</li>
</ul>
</nav><!-- Navegador inferior -->
</div><!-- Navegador Inferior -->
The key is to set the dropdown to visility:hidden; in the start and visility:visible; in :hover state.
.fixed-top {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
top: 0;
border-width: 0 0 1px;
}
#nav ul li a {
display: block;
padding: 7px 15px;
text-decoration: none;
font-weight: bold;
color: #FFFFFF;
}
#nav li a:hover {
color: #000000;
background-color: #fff;
}
#nav .navbar-izquierda ul {
width: 100%;
float: left;
margin: auto;
padding: 0;
list-style: none;
background-color: #434343;
box-shadow: 10px 0 10px #000000;
border-bottom: 1px solid #000000;
}
.clearfix:after {
display:block;
clear:both;
}
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width: auto;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
.menu > ul > li {
float:left;
display:inline-block;
position:relative;
font-size:14px;
}
.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;
}
/*----- DropDown Navbar Inferior -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
visibility:visible;
}
.sub-menu {
width:100%;
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;
visibility:hidden;
}
.sub-menu li {
display:block;
font-size:16px;
}
.sub-menu li a {
padding:10px 30px;
display:inline-block;
}
.sub-menu li a:hover, .sub-menu .current-item a {
background:#3e3436;
}
<div class="navbar-izquierda menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li class="active">Portatil</li>
<li>Desk</li>
<li>Workstation</li>
<li>Promotions</li>
<li>Services and Guarantees <span class="arrow">▼</span>
<ul class="sub-menu">
<li>Error 1</li>
<li>Error 2</li>
<li>Horror 3</li>
</ul>
</li>
</ul>
</nav><!-- Navegador inferior -->
</div><!-- Navegador Inferior -->
I am having extreme dificulties to add a sub-menu to my dropdown, but I am not a pro on css. I would like to put a submenu on the part it says "10º ano" and "11º ano" in the dropdown "projects", but everything I do doesn't work ! How can I put submenus and open on the right side when cursor is placed ?
---------------------------------------Here is the HTML -------------------------
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Sobre mim</li>
<li>Sobre o curso</li>
<li>
Projectos <span class="arrow">▼</span>
<ul class="sub-menu">
<li>10∘ Ano <span class="arrow">▶ </span> </li>
</li>
<li>11∘ Ano <span class="arrow">▶ </span>
<ul>
</ul>
</li>
</li>
</ul>
</li>
<li>Contactos</li>
</ul>
</nav>
</div>
--------------------------------------------------and here is css ----------------------------------
<style>
<!-- cor rosa #be5b70 -->
.clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0,0,0,0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.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:#3e3436;
border-radius: 10px;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
}
.sub-menu {
width:130%;
text-align: center;
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;
border-radius: 10px;
}
.sub-menu li {
display:block;
font-size:16px;
}
.sub-menu li a {
padding:10px 7px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a {
background:#3e3436;
border-radius: 10px;
}
.sub-menu li:hover > a, .menu .current-item > a {
text-decoration: none;
color:#E68268;
<!-- lalalalalalal separador-->
li.sub-menu li {
display:none;
position: absolute; left: 100%; top:0;}
li.sub-menu:hover li{
display: block;}
</style>
<!-- cor rosa #be5b70 --> .clearfix:after {
display:block;
clear:both;
}
/*----- Menu Outline -----*/
.menu-wrap {
width:100%;
box-shadow:0px 1px 3px rgba(0, 0, 0, 0.2);
background:#3e3436;
}
.menu {
width:1000px;
margin:0px auto;
}
.menu li {
margin:0px;
list-style:none;
font-family:'Ek Mukta';
}
.menu a {
transition:all linear 0.15s;
color:#919191;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration:none;
color:#be5b70;
}
.menu .arrow {
font-size:11px;
line-height:0%;
}
/*----- Top Level -----*/
.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:#3e3436;
border-radius: 10px;
}
/*----- Bottom Level -----*/
.menu li:hover .sub-menu {
z-index:1;
opacity:1;
}
.sub-menu {
width:130%;
text-align: center;
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;
border-radius: 10px;
}
.sub-menu li {
display:block;
font-size:16px;
position: relative;
}
.sub-menu li a {
padding:10px 7px;
display:block;
}
.sub-menu li a:hover, .sub-menu .current-item a {
background:#3e3436;
border-radius: 10px;
}
.sub-menu li:hover a, .menu .current-item a {
text-decoration: none;
color:#E68268;
}
/* li.sub-menu li {
display:none;
position: absolute;
left: 100%;
top:0;
}
li.sub-menu:hover li {
display: block;
}*/
.sub-menu li ul {
display: none;
}
.sub-menu li:hover ul {
display: block;
width: 100%;
position: absolute;
left: 100%;
top: 0;
text-align: center;
padding:5px 0px;
transition:opacity linear 0.15s;
box-shadow:0px 2px 3px rgba(0, 0, 0, 0.2);
background:#2e2728;
border-radius: 10px;
}
<div class="menu-wrap">
<nav class="menu">
<ul class="clearfix">
<li>Sobre mim</li>
<li>Sobre o curso</li>
<li><a href="#">
Projectos <span class="arrow">▼</span></a>
<ul class="sub-menu">
<li>10∘ Ano <span class="arrow">▶ </span>
<ul>
<li>1Ano </li>
<li>1Ano </li>
</ul>
</li>
<li>11∘ Ano <span class="arrow">▶ </span>
<ul>
<li>1Ano </li>
<li>1Ano </li>
</ul>
</li>
</ul>
</li>
<li>Contactos
</li>
</ul>
</nav>
</div>
this is sort of a continuation of this solved question.
as you can see in this fiddle the 3rd level dropdown is working but the fix has created this unexplainable single pixel transparent border at the bottom of the dropdowns. You can see it if you look closely between the dropdown and the box-shadow.
html:
<nav id="menu" class="dark_menu">
<!-- Main Nav Start -->
<ul id="main-nav" class="clearfix">
<li id="port" class="parent menu-item">Portfolio
<ul class="clearfix">
<li id="regular" class="parent menu-item">Regular
<ul class="clearfix">
<li id="menu-item-1036" class="menu-item">4 columns
</li>
<li id="menu-item-1033" class="menu-item">3 columns
</li>
<li id="menu-item-1030" class="menu-item">3 columns w/ sidebar
</li>
<li id="menu-item-1029" class="menu-item">2 columns
</li>
</ul>
</li>
<li id="2col" class="parent menu-item">Ajax
</li>
</ul>
</li>
<li id="menu-item-1727" class="parent menu-item">About
<ul class="clearfix">
<li id="menu-item-870" class="menu-item">Who We Are
</li>
<li id="menu-item-872" class="menu-item">What We Do
</li>
</ul>
</li>
</ul>
</nav>
css:
a {
text-decoration:none;
}
ul {
padding-left:0px;
}
#menu {
position:relative;
border:none;
height:auto;
top:34px;
left:0px;
}
#menu ul {
margin:0;
list-style:none;
}
#menu li {
float:left;
position:relative;
}
#menu > ul > li > a {
padding:25px 26px 17px;
border-bottom:3px solid transparent;
margin-right:1px;
color:#6B6B6B;
font:11px Arial, sans-serif;
font-weight:bold;
text-align:center;
text-transform:uppercase;
display:block;
}
#menu > ul > li:hover > a {
color:#F15A2B;
border-color:#F15A2B;
}
#menu > ul li.selected > a, #menu > ul li.selected:hover > a {
color:#3B3B3B;
border-color:#3B3B3B;
}
/* Submenu (second level) */
#menu li > ul {
position:absolute;
top:auto;
left:0;
width:180px;
max-height:0;
box-shadow:1px 2px 10px rgba(100, 100, 100, 0.3);
visibility: hidden;
z-index:99999;
overflow:hidden;
-webkit-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-moz-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-o-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
-ms-transition: max-height 0.2s ease, visibility 0s linear 0.5s;
transition: max-height 0.2s ease, visibility 0s linear 0.5s;
background: inherit !important;
}
#menu ul li:hover > ul {
visibility: visible;
max-height: 216px;
transition-delay: 0s;
}
#menu ul li > ul:hover {
overflow:visible;
}
#menu li > ul li {
height:36px;
width:100%;
border-bottom:1px solid #EEE;
padding-top:0;
}
#menu li > ul li:last-child {
border-bottom:none;
}
#menu li > ul li a {
background:#FFF;
padding:11px 15px;
height:35px;
color:#999;
width:100%;
font:10px Arial, sans-serif;
font-weight:bold;
text-align:left;
text-transform:uppercase;
display:block;
}
#menu li > ul li:hover > a {
color:#FFF;
background:#F15A2B;
}
#menu li > ul li.selected > a, #menu li > ul li.selected:hover > a {
color:#3B3B3B;
background:#FFF;
}
/* Submenu (third level) */
#menu li > ul > li > ul {
position:absolute;
top:0 !important;
left:180px !important;
width:180px;
overflow:hidden;
box-shadow:1px 2px 10px rgba(100, 100, 100, 0.3);
visibility:hidden;
}
#menu li > ul > li:hover > ul {
visibility: visible;
}
#menu li > ul > li > ul > li:last-child {
border-bottom:none;
}
#menu li > ul li ul li a {
background:#FFF;
padding:11px 15px;
height:35px;
color:#999;
font:10px Arial, sans-serif;
font-weight:bold;
text-align:left;
text-transform:uppercase;
display:block;
}
#menu li > ul > li > ul > li:hover > a {
color:#FFF;
background:#F15A2B;
}
#menu li > ul li.selected > a, #menu li > ul li.selected:hover > a {
color:#3B3B3B;
background:#FFF;
}
/* Dark Menu */
#menu.dark_menu li ul li {
border-color:#464646;
}
#menu.dark_menu li ul li a {
background:#3B3B3B;
color:#999;
}
#menu.dark_menu li ul li:hover > a {
color:#FFF;
background:#F15A2B;
}
#menu.dark_menu li ul li.selected > a, #menu.dark_menu li ul li.selected:hover > a {
color:#FFF;
background:#3B3B3B;
}
* {
box-sizing:border-box;
-moz-box-sizing:border-box;
}
It looks like adding the following CSS below fixes your issue. If you want to remove the border on the last item, you have to make sure the element does not extend past its child height which is the only element with the background color.
#menu li > ul li:last-child {
border-bottom:none;
height: 35px;
}
I have a dropdown bar -
<div class="buttonContainer">
<ul>
<li>
<a class="menu1one" href="">Dashboard</a>
</li>
</ul>
<ul>
<li>
<div class="noLink">Tasks</div>
<ul>
<li>View</li>
<li>Edit</li>
<!--[if lte IE 6]></a><![endif]-->
</ul>
<!--[if lte IE 6]></a><![endif]-->
</li>
<li>
<div class="noLink">Dictionaries</div>
<ul>
<li>Needs</li>
<li>Activities</li>
</ul>
<!--[if lte IE 6]></a><![endif]-->
</li>
<li>
<div class="noLink">Admin</div>
<ul>
<li>User Accounts</li>
</ul>
<!--[if lte IE 6]></a><![endif]-->
</li>
</ul>
</div>
CSS -
/*dropdown menu*/
.menu { float:left; width:100%; font-family: arial; border-top:1px solid #4c597f; background-color: #1079b5; min-width:950px; }
.menu .buttonContainer { padding:0 0 0 200px; }
.menu ul { padding:0; margin:0; list-style-type:none; }
.menu ul li { margin:0; float:left; position:relative; background-color:#153d71; }
.menu ul li a, .menu ul li a:visited { float:left; display:block; text-decoration:none; color:#ddf; padding:0px 16px; line-height:25px; height:30px; }
.menu ul li a:hover { background-color:#9fc1ed; color: #153d71;}
.noLink { display:block; color:#ddf; padding:0px 16px; line-height:25px; height:30px; }
.menu ul li:hover { width:auto; }
.menu ul li ul { display: none; }
/* specific to non IE browsers */
.menu ul li:hover ul { display:block; position:absolute; top:30px; left:0; width:154px; border-bottom:1px solid #000; }
.menu ul li:hover ul.endstop { left:-92px; }
.menu ul li:hover ul li ul { display: none; }
.menu ul li:hover ul li a { display:block; background:#1079b5; color:#000; height:auto; line-height:15px; padding:4px 16px; width:120px; border:1px solid #000; border-bottom:0; }
.menu ul li:hover ul li a.drop { background:#ccd no-repeat 3px 8px; }
.menu ul li:hover ul li a:hover { background-color: #153d71; color: #FFFFFF; }
.menu ul li:hover ul li a:hover.drop { background: #ccd no-repeat 3px 8px; }
.menu ul li:hover ul li:hover ul { display:block; position:absolute; left:153px; top:-1px; }
.menu ul li:hover ul li:hover ul.left { left:-153px; }
/* IE6 */
.menu ul li a:hover ul { display:block; position:absolute; top:30px; t\op:33px; background:#153d71; left:0; border-bottom:1px solid #000; }
.menu ul li a:hover ul.endstop { left: -92px; }
.menu ul li a:hover ul li a { display:block; background:#153d71; color:#000; height:1px; line-height:15px; padding:4px 16px; width:154px; w\idth:120px; border:1px solid #000; border-bottom:0; }
.menu ul li a:hover ul li a.drop { background:#ccd url('') no-repeat 3px 8px; padding-bottom:4px; }
.menu ul li a:hover ul li a ul { visibility:hidden; position:absolute; height:0; width:0; }
.menu ul li a:hover ul li a:hover { color:#000; background: #ccd url('') no-repeat 3px 8px; }
.menu ul li a:hover ul li a:hover.drop { background: #ccd url('') no-repeat 3px 8px; }
.menu ul li a:hover ul li a:hover ul { visibility:visible; position:absolute; top:0; color:#000; left:153px; }
.menu ul li a:hover ul li a:hover ul.left { left:-153px; }
The dropdown menu is working well or showing up on hover in IE7 but not responding in Firefox.
Could anybody help me with this please?? I tried position : relative for inner li a:hover and it shows the menu but extends the whole div till its end. What is to be changed here?
Also, i don't want to use javascript/jquery for this.
-thanks
EDITED - I have found the solution to get it to work. I added 'position: absolute;' attribute to the .menu{} in the css. That made it work... Thanks.
I just tested on IE7 its working fine to me
http://jsfiddle.net/vcN5g/
I have found the solution to get it to work. I added 'position: absolute;' attribute to the .menu{} in the css. That made it work... Thanks.