Reputation: 49
Good morning,
I have been playing around with a pure CSS navigation drop-down menu and have come across a problem and was wondering if anyone could help.
I want the page that I am on to stay highlighted in white text with a green background like it does when you hover over it, I also want MENU 1 and MENU 2 to stay highlighted with white text when I hover over their sub-menus. I also am having massive trouble putting the bar into the center of the page or just a div container, I have tried other suggestions and can't get it to center.
Many thanks
Upvotes: 0
Views: 69
Reputation: 202
add in css
#menu ul li.-item
{
background:#70B51E;
color: #FFFFFF;
}
#menu ul li:hover a {
color: #fff;
}
And also check this link
Upvotes: 0
Reputation: 270
You can try the following code.
#menu
{
margin: 10px auto;
width: 100%;
display: inline-block;
list-style-type: none;
}
#menu ul
{
list-style:none;
position:relative;
margin:0;
padding:0;
text-align: center;
}
#menu ul a
{
display:block;
color:#000000;
text-decoration:none;
font-size:15px;
line-height:32px;
padding:0 15px;
font-family:arial, verdana, sans-serif;
}
#menu ul a:hover
{
color:#FFFFFF;
}
#menu ul a:active
{
color:#FFFFFF;
}
#menu ul li
{
position:relative;
/*float:left;*/
display: inline-block;
margin:0;
padding:0
}
#menu ul li.current-menu-item
{
background:#70B51E;
color: #FFFFFF;
}
.current-MENU,
#menu ul li:hover
{
background:#70B51E;
color:#ffffff;
}
#menu ul li:hover > a,
.current-MENU > a{
color: #fff !important;
}
#menu ul ul
{
display:none;
position:absolute;
color:#FFFFFF;
top:100%;
left:0;
background:#fff;
padding:0
}
#menu ul ul li
{
float:none;
color:#FFFFFF;
width:200px
}
#menu ul ul a
{
line-height:120%;
color:#FFFFFF;
border-top: 4px solid #70B51E;
border-bottom: 4px solid #70B51E;
border-right: 4px solid #70B51E;
border-left: 4px solid #70B51E;
background:#70B51E;
padding:10px 15px
}
#menu ul ul a:active
{
line-height:120%;
color:#FFFFFF;
background:#70B51E;
padding:10px 15px
}
#menu ul ul a:hover
{
line-height:120%;
color:#FFFFFF;
background:#3F96A9;
padding:10px 15px
}
#menu ul ul ul
{
top:0;
left:100%
}
#menu ul li:hover > ul
{
display:block;
color: #FFFFFF;
}
<div id="menu">
<ul>
<li class="current-MENU -item"><a href="#">MENU </a></li>
<li><a href="#">MENU 1</a>
<ul>
<li><a href="#">SUB-MENU 1</a></li>
<li><a href="#">SUB-MENU 2</a></li>
<li><a href="#">SUB-MENU 3</a></li>
</ul>
<li><a href="#">MENU 2</a>
<ul>
<li><a href="#">SUB-MENU 1</a></li>
<li><a href="#">SUB-MENU 2</a></li>
</ul>
</li>
<li><a href="#">MENU 3</a></li>
<li><a href="#">MENU 4</a></li>
</ul>
</div>
Upvotes: 1