Hover Menu Delayed Close? - html

I want to add a delay on mouse out from hover menu. Here is my codepen: http://codepen.io/anon/pen/MYjzVb
Please notice that I have used these lines for CSS transitions:
-webkit-transition: visibility 0.65s ease-in;
-moz-transition: visibility 0.65s ease-in;
But this doesn't works. I am using Chrome browser, tried to view it in Firefox too but that doesn't helps.
Please help!

1- WITHOUT ANIMATION:
/**RESETING BROWSER STYLE*/
*{box-sizing: border-box; padding: 0; margin: 0}
/**SETTING THE ROOT ELEMENT BACKGROUND*/
:root{background: #ccc}
/**REMOVING THE STYLE ON ALL LIST IN [id=panel]*/
[id=panel] li{
list-style-type: none
}
/**INIT OUR DROP MENU*/
.drop_menu {
background: #10BDF5;
height: 25px
}
/* SUBMENU position:absolute AND OPACITY INSTEAD OF VISIBILITY and ease-out not ease-in*/
.drop_menu ul {
position: absolute;
left: 0;
top: 28px;
height: 0; /**SET THIS TO ZERO SINCE WE CAN'T ANIMATE display: none*/
overflow: hidden; /**YOU NEED THIS TO HIDE THE LIST*/
background:#51C7ED;
border-bottom: 5px solid transparent;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
opacity: 0; /**DO NOT DISPLAY THE LIST ON INIT STATE*/
transition:opacity 0 5s linear, height 0 5s linear,border-bottom 0 5s linear/**TRANSITION ON OPACITY WITHOUT DELAY BUT ON HEIGHT WITH A DELAY GREATER OR EGAL THE OPACITY ANIMATION DURATION*/
}
.drop_menu li:hover ul {
transition:height 0s ease-out ;/**TRANSITION ONLY ON HEIGHT*/
opacity: 1;
border-bottom: 5px solid #1292BB;
height: 76px /**SET THE HEIGHT ON MOUVE IN*/
}
/**GIVING position: relative TO THE PARENT OF OUR UNORDERED LIST SINCE IT HAS position:absolute */
.drop_menu li { float:left; position: relative}
.drop_menu li a {
padding:3px 6px;
display:block;
color:#FFF;
text-decoration:none;
font-size: 11px;
line-height: 22px;
}
.drop_menu li:hover { position:relative; background:#51C7ED; }
.drop_menu ul a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a:hover { background:#51C7ED }
#panel {
background: #10BDF5;
color: #FFF;
font-size: 11px;
text-align: left;
border: 1px solid #30B3DE;
padding: 3px 4px
}
<div id="panel">
<ul class="drop_menu">
<li>Upgrade Account</li>
<li>Link One
<ul>
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
</li>
<li>Link Two</li>
</ul>
</div>
2- WITH ANIMATION
/**RESETING BROWSER STYLE*/
*{box-sizing: border-box; padding: 0; margin: 0}
/**SETTING THE ROOT ELEMENT BACKGROUND*/
:root{background: #ccc}
/**REMOVING THE STYLE ON ALL LIST IN [id=panel]*/
[id=panel] li{
list-style-type: none
}
/**INIT OUR DROP MENU*/
.drop_menu {
background: #10BDF5;
height: 25px
}
/* SUBMENU position:absolute AND OPACITY INSTEAD OF VISIBILITY and ease-out not ease-in*/
.drop_menu ul {
position: absolute;
left: 0;
top: 28px;
height: 0; /**SET THIS TO ZERO SINCE WE CAN'T ANIMATE display: none*/
overflow: hidden; /**YOU NEED THIS TO HIDE THE LIST*/
background:#51C7ED;
border-bottom: 5px solid transparent;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
opacity: 0; /**DO NOT DISPLAY THE LIST ON INIT STATE*/
transition:opacity 0.65s ease-out, height 0 0.68s linear /**TRANSITION ON OPACITY WITHOUT DELAY BUT ON HEIGHT WITH A DELAY GREATER OR EGAL THE OPACITY ANIMATION DURATION*/
}
.drop_menu li:hover ul {
transition:height 0s ease-out ;/**TRANSITION ONLY ON HEIGHT*/
opacity: 1;
border-bottom: 5px solid #1292BB;
height: 76px /**SET THE HEIGHT ON MOUVE IN*/
}
/**GIVING position: relative TO THE PARENT OF OUR UNORDERED LIST SINCE IT HAS position:absolute */
.drop_menu li { float:left; position: relative}
.drop_menu li a {
padding:3px 6px;
display:block;
color:#FFF;
text-decoration:none;
font-size: 11px;
line-height: 22px;
}
.drop_menu li:hover { position:relative; background:#51C7ED; }
.drop_menu ul a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a {
padding:1px 4px;
display:block;
width:150px;
font-size: 11px;
text-indent:11px;
background-color:#10BDF5;
}
.drop_menu li:hover ul li a:hover { background:#51C7ED }
#panel {
background: #10BDF5;
color: #FFF;
font-size: 11px;
text-align: left;
border: 1px solid #30B3DE;
padding: 3px 4px
}
<div id="panel">
<ul class="drop_menu">
<li>Upgrade Account</li>
<li>Link One
<ul>
<li>link</li>
<li>link</li>
<li>link</li>
</ul>
</li>
<li>Link Two</li>
</ul>
</div>

You could use JavaScript for handling mouseenter and mouseleave events and use setTimeout() for the delay(5s) on mouseleave event.
You could set the delay through the variable delay.
Updated CodePen
var items = document.querySelectorAll('.drop_menu > li');
var delay = 5000;
for (i = 0; i < items.length; i++) {
items[i].addEventListener('mouseenter', function() {
var c = this.children
for (j = 0; j < c.length; j++) {
if (c[j].localName == 'ul') {
c[j].style.display = 'block';
c[j].style.position = 'absolute';
}
}
});
items[i].addEventListener('mouseleave', function() {
mouseLeave(this, j);
});
}
function mouseLeave(el, j) {
setTimeout(function() {
var c = el.children;
for (j = 0; j < c.length; j++) {
if (c[j].localName == 'ul') {
c[j].style.display = 'none';
}
}
}, delay)
}
.drop_menu {
background: #10BDF5;
padding: 0;
margin: 0;
list-style-type: none;
height: 25px;
}
.drop_menu li {
display: inline-block;
}
.drop_menu li a {
padding: 3px 6px;
display: block;
color: #FFF;
text-decoration: none;
font-size: 11px;
line-height: 22px;
}
/* Submenu */
.drop_menu ul {
position: absolute;
display: none;
list-style-type: none;
}
.drop_menu > li {
position: relative;
}
.drop_menu li:hover {
background: #51C7ED;
}
.drop_menu li ul {
left: 0px;
top: 28px;
background: #51C7ED;
padding: 0px;
border-bottom: 5px solid #1292BB;
border-bottom-right-radius: 3px;
border-bottom-left-radius: 3px;
}
.drop_menu li ul li a {
padding: 1px 4px;
display: block;
width: 150px;
font-size: 11px;
text-indent: 11px;
background-color: #10BDF5;
}
.drop_menu li:hover ul li a:hover {
background: #51C7ED;
}
#panel {
background: #10BDF5;
color: #FFF;
font-size: 11px;
text-align: left;
border: 1px solid #30B3DE;
padding: 3px 4px;
}
<div id="panel">
<ul class="drop_menu">
<li>Upgrade Account
</li>
<li>Link One
<ul>
<li>link
</li>
<li>link
</li>
<li>link
</li>
</ul>
</li>
<li>Link Two
</li>
</ul>
</div>

Related

Delaying hover effect for menu

I want to use this style
Site > Then choose the Zerus theme.
The CSS for Zerus is as follows:
#charset "utf-8";
/* CSS Document */
#import url('https://fonts.googleapis.com/css?family=Open+Sans:400,600');
/* Fonts */
body {
font-family: 'Open Sans', sans-serif;
}
h1, h2, h3, h4, h5, h6, #content a, ul.lw-hmenu a, .lw-hmenu li span.nav-header, #lw-topnav ul a, #lw-topnav ul li span.nav-header {
font-weight: 600;
}
#content a::after {
content: "→";
padding-left: 5px;
}
#content div.pagination ul li a::after {
content: "";
padding-left: 0;
}
/* End Fonts */
/* Colors */
:root{
--primary: #24b47e;
--accent: #6772e5;
--accent2: #b76ac4;
--ux: rgba(255, 255, 255, 0.95);
--ux-border: #6b7c93;
}
.lw_svg_logo {
fill: var(--primary);
}
#masterPage {
background-color:#F6F9FC;
}
#contentPage {
background-color: #F6F9FC;
}
body {
color:#6b7c93;
}
a, span.nav-header {
color: var(--accent);
}
/* End Colors */
#media screen and (min-width: 768px) {
#lw-topnav {
box-shadow: 0px 2px 5px rgba(0, 0, 0, 0.3);
border-bottom: 9px solid var(--ux-border);
}
#lw-topnav ul>li:hover {
background-color: rgba(0, 0, 0, 0.05);
}
#lw-topnav ul li ul {
border-radius: 15px;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5);
margin-top:15px !important;
}
#lw-topnav ul li ul::before {
display:block;
content: "";
width:20px;
height:20px;
background-color: var(--ux);
position:relative;
left:50%;
margin-top:5px;
transform: translateX(-50%) rotateZ(45deg);
z-index:1;
top:-15px;
}
#lw-topnav ul li ul::after {
display:block;
content: "";
height:9px;
background-color: var(--ux-border);
z-index:1;
border-bottom-right-radius: 15px;
border-bottom-left-radius: 15px;
}
#lw-topnav ul li ul li ul {
border-radius: 8px;
margin-top: 0px !important;
}
#lw-topnav ul li ul li ul::before {
display:none;
}
#lw-topnav ul>li:hover:after{
content:"";
position:absolute;
left:0;
right:0;
top:0px;
height:120%;
z-index:-1;
}
}
I would like to lower the menu that appears when you hover over the top navigation by about 15px. If I do however, then I can't actually get to the sub-menu because the mouse leaves the <li> that contains the hover effect to make it visible, so the menu disappears.
You can see the effect I want by adding this:
#lw-topnav ul li ul {
margin-top:15px !important;
}
I think this can be achieved by using a transition-delay, but no matter where I put it, it doesn't seem to have any effect. I'd like to avoid using javascript if I have to. Can anyone help on where to add the transition-delay?
Thanks
The problem you have is, that your mouse leaves the <li> of the top list, so the hover-event is not working anymore. You have to seperate the display of the sublist and the area where the list item is considered as "hovered".
These are two things, while you see the list itself, you cannot see the area where the program accepts the item as "hovered".
I created a little example by copying and modifying code from SelfHTML where I point out the problem you face.
If you modify the values I highlighted you see the difference.
<html>
<head>
<style>
nav {
border: 1px solid black;
height: 2em;
padding: 0.8em;
width: 50em;
}
nav ul {
margin: 0;
padding: 0;
text-align: center;
}
nav li {
float: left;
list-style: none;
margin: 0;
padding: 0;
position: relative;
}
/* important here */
nav ul ul {
font: 0/0 serif;
margin-top: 40px; /*this changes the display of the sublist*/
padding: 0;
position: absolute;
top: 0em;
/*change this to shift the space where your cursor stays with the sublist*/
z-index: -1;
-webkit-transition: all 0.5s ease-in;
transition: all 0.5s ease-in;
}
nav ul li:hover ul {
font: inherit;
z-index: auto;
color: red;
}
nav ul ul li {
float: none;
margin-bottom: 0.2em;
}
nav a,
nav span {
background-color: royalblue;
border: 1px solid blue;
border-radius: 10px 10px 0 0;
box-shadow: 0px 5px 10px white inset;
color: gold;
display: block;
font-weight: bold;
margin: 0.6em 0 0 0;
padding: 0.4em;
width: 6.4em;
-webkit-transition: all 0.5s ease-in;
transition: all 0.5s ease-in;
}
nav ul ul a,
nav ul ul span {
border-radius: 10px;
}
nav a:focus,
nav a:hover,
nav span
{
color: royalblue;
background-color: gold;
}
nav a:focus,
nav a:hover {
margin-top: 0;
padding: 1em 0.4em 0.4em;
}
nav ul ul a:hover {
margin: 0.6em 0 0 0;
padding: 0.4em;
}
nav ul ul span {
background-color: maroon;
color: gold;
}
</style>
</head>
<body>
<nav>
<ul>
<li>Seite 1</li>
<li>Seite 2
<ul>
<li>Seite 2a</li>
<li>Seite 2b</li>
</ul>
</li>
<li>Seite 3</li>
<li>Seite 4
<ul>
<li>Seite 4a</li>
<li><span>aktuelle Seite</span></li>
<li>Seite 4c</li>
</ul>
</li>
<li>Seite 5</li>
</ul>
</nav>
</body>
</html>
Make sure that your mouse is always hovering the selected list item by modifying the top:0em to 0 or even below 0. To balance the fact that your menu will move upward, simply adjust the margin-top in the same frame! This all has to happen in the sublist itself nav ul ul and of course with another level of depth if you create a list like that! :)
I fixed it by adding an invisible div behind it.
#lw-topnav ul>li:hover:after{
content:"";
position:absolute;
left:0;
right:0;
top:0px;
height:120%;
z-index:-1;
}
That being said. I think S.M.'s solution is better. I'll play around with it more.

dropdown menu without borders

I want to do one small and easy dropdown menu, but I dont get it how to do this.
What I exacly mean ? :
And I want to do this thisway: If u click on ENG then its going to index_eng.html, but its not working.
My html:
<nav id="menu2">
<select>
<option href="index.html" value="est">EST</option>
<option href="index_eng.html" value="eng">ENG</option>
</select>
</nav>
My css:
#menu2 {
height: 30px;
overflow: visible;
border-radius: 5px;
background-color: #484848;
color: #FFFFFF;
padding: 5px 5px 0px 5px;
margin: 5px 5px 5px 5px;
font: 8pt verdana, arial, sans-serif;
}
At the moment I have this menu like this, but I want it like this picture above.
Need some clue or solution. Thank you!
Why don't you use anchors?
<nav id="menu2">
<ul>
<li>EST</li>
<li>ENG</li>
</ul>
</nav>
If you do not want to use anchors, you can achieve navigation with jQuery:
$('option').click(function() {
var url = $(this).attr('href');
window.location = url;
});
Try this if the above does not work:
window.location.assign(url);
This is very simple CSS3 drop-down menu:
Demo: http://jsfiddle.net/ahqbbwbm/11/
HTML
<ul>
<li>
EST <span class="arrow-down"></span>
<ul>
<li>EST</li>
<li>ENG</li>
</ul>
</li>
</ul>
CSS
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #2980b9;
cursor: pointer;
-webkit-transition: all 0.2s;
-moz-transition: all 0.2s;
-ms-transition: all 0.2s;
-o-transition: all 0.2s;
transition: all 0.2s;
color: #fff;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
display: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.2s;
-moz-transition: opacity 0.2s;
-ms-transition: opacity 0.2s;
-o-transition: opacity 0.2s;
-transition: opacity 0.2s;
}
ul li ul li {
min-width: 80px;
background-color: #555;
}
ul li ul li > a {
text-decoration: none;
display: block;
color: #fff;
}
ul li ul li:hover {
background: #666;
}
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
}
ul li > span {
display: inline-block;
margin: 0 0 -3px 5px;
width: 12px;
height: 12px;
background-image: url('https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/down4-24.png'); /* Change this */
background-size: 12px 12px;
}
http://jsfiddle.net/yf18w6ay/
css
select{
border:0px;
outline:0px;
}
Below is the example for simple pure CSS Drop Down Menu..
HTML
<nav id="primary">
<ul>
<li>Menu 1
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
<li>Sub Menu 4
<ul>
<li>Deep Menu 1
</li>
<li>Deep Menu 2</li>
</ul>
</li>
<li>Sub Menu 5</li>
</ul>
</li>
</ul>
CSS
#primary
{
margin-top:15px
}
#primary ul
{
list-style:none;
position:relative;
float:left;
margin:0;
padding:0
}
#primary ul a
{
display:block;
color:#333;
text-decoration:none;
font-weight:700;
font-size:12px;
line-height:32px;
padding:0 15px;
font-family:"HelveticaNeue","Helvetica Neue",Helvetica,Arial,sans-serif
}
#primary ul li
{
position:relative;
float:left;
margin:0;
padding:0
}
#primary ul li.current-menu-item
{
background:#ddd
}
#primary ul li:hover
{
background:#f6f6f6
}
#primary ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background:#fff;
padding:0
}
#primary ul ul li
{
float:none;
width:200px
}
#primary ul ul a
{
line-height:120%;
padding:10px 15px
}
#primary ul ul ul
{
top:0;
left:100%
}
#primary ul li:hover > ul
{
display:block
}

Need make pure css menu with 3 level

I make pure css menu with 2 levels .But now I need to make it 3 levels .I tried many time but not working for me . here is the jsfiddle .
I don't need any jquery code, just pure css .
CSS
#menu {
width: 980px;
height: 30px;
float: left;
border-top: dashed 1px #d8d8d8;
margin-left: 7px;
}
#menu ul.Mainmenu {
width: 996px;
margin: 0px;
padding: 0px;
margin-top: 10px;
}
#menu ul.Mainmenu li {
float: left;
list-style: none;
margin-right: 20px;
font-family: Verdana, Geneva, sans-serif;
font-size: 14px;
color: #860300;
margin-right: 16px\9; /* IE8 and below */
position: relative;
height: 30px;
}
#menu ul.Mainmenu li a {
text-decoration: none;
font-family: Verdana, Geneva, sans-serif;
font-size: 13px;
color: #860300;
}
ul li ul {
padding: 0;
position: absolute;
top: 25px;
left: -10px;
width: 190px;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
opacity: 0;
visibility: hidden;
-webkit-transiton: opacity 0.5s;
-moz-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-transition: opacity 0.5s;
z-index: 100000;
width: 200px;
background-color: #FFF;
padding: 7px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
ul li ul li {
color: #fff;
float: left;
width: 190px;
height: auto !important;
min-height: 20px;
margin-bottom: 9px;
line-height: 18px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
padding-top: 3px;
padding-left: 3px;
}
ul li ul li a {
color: #fff;
font-size: 12px !important;
}
ul li ul li:hover {
background: #820B06;
color: #FFF;
}
ul li ul li:hover a {
color: #FFF !important;
}
ul li:hover ul {
opacity: 1;
visibility: visible;
}
Thanks guys
See this example
css
#nav ul{
margin:0;
padding:0;
list-style:none;
}
#nav ul li{
margin:0;
padding:10px 20px;
position:relative;
height:20px;
line-height:20px;
background-color:#EEE;
}
#nav > ul > li {
float: left;
height:30px;
line-height:30px;
background-color:#CCC;
}
#nav li > ul{
visibility:hidden;
width:200px;
position: absolute;
top:0px;
left:200px;
border-left:1px solid #000;
}
#nav > ul > li > ul{
top:50px;
left:0;
}
#nav li:hover{
background-color:#999;
}
#nav li:hover > ul{
visibility:visible;
}
html
<div id="nav">
<ul>
<li>Level 1
<ul>
<li>Level 2-1</li>
<li>Level 2-2
<ul>
<li>Level 3-1</li>
<li>Level 3-2</li>
</ul>
</li>
</ul>
</li>
</ul>
Here i added sample CSS Menu with level 3. Please check and let me know. Hope it should helpful for you. Thanks.
.third-level-menu
{
position: absolute;
top: 0;
right: -150px;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.third-level-menu > li
{
height: 30px;
background: #999999;
}
.third-level-menu > li:hover { background: #CCCCCC; }
.second-level-menu
{
position: absolute;
top: 30px;
left: 0;
width: 150px;
list-style: none;
padding: 0;
margin: 0;
display: none;
}
.second-level-menu > li
{
position: relative;
height: 30px;
background: #999999;
}
.second-level-menu > li:hover { background: #CCCCCC; }
.top-level-menu
{
list-style: none;
padding: 0;
margin: 0;
}
.top-level-menu > li
{
position: relative;
float: left;
height: 30px;
width: 150px;
background: #999999;
}
.top-level-menu > li:hover { background: #CCCCCC; }
.top-level-menu li:hover > ul
{
/* On hover, display the next level's menu */
display: inline;
}
/* Menu Link Styles */
.top-level-menu a /* Apply to all links inside the multi-level menu */
{
font: bold 14px Arial, Helvetica, sans-serif;
color: #FFFFFF;
text-decoration: none;
padding: 0 0 0 10px;
/* Make the link cover the entire list item-container */
display: block;
line-height: 30px;
}
.top-level-menu a:hover { color: #000000; }
<ul class="top-level-menu">
<li>About</li>
<li>Services</li>
<li>
Offices
<ul class="second-level-menu">
<li>Chicago</li>
<li>Los Angeles</li>
<li>
New York
<ul class="third-level-menu">
<li>Information</li>
<li>Book a Meeting</li>
<li>Testimonials</li>
<li>Jobs</li>
</ul>
</li>
<li>Seattle</li>
</ul>
</li>
<li>Contact</li>
</ul>
I have also put together a live demo here http://jsfiddle.net/4ScFz/400/ that's available to play with.

When I hover over my nav menu it pushes content down, why? How do i change color of li when hover over?

When i hover over the navmenu it pushes other content down on the webpage. In addition, when you hover over the nav the font is no longer in white. I'm sorry I am new at programming and borrowed some of this code so it may be sloppy. Thanks
Here is my html:
<div class="nav">
<ul id="nav">
<li>Home</li>
<li>Shop Online</li>
<li>Online Rentals
<div>
<ul>
<li>Rent Now</li>
<b>Current Rental Customers</b>
<li>Rental Returns</li>
<li>Rental Repairs</li>
<li>Rental Exchanges</li>
</ul>
</div>
</li>
<li>Lessons
<div>
<ul>
<li>Private Lessons</li>
<li>Meet the Teachers</li>
<li>Request a Lesson</li>
</ul>
</div>
</li>
<li>Performing Arts Center
<div>
<ul>
<li>Musical Theater</li>
<li>Kindermusik</li>
<li>Recording Studio</li>
<li>Group Ensembles</li>
</ul>
</div>
</li>
<li>Repairs</li>
<li>My Account</li>
</ul>
</div>
Here is my css:
/* main menu styles */
#nav,#nav ul {
font-family: verdana;
list-style: none;
margin: 0;
padding: 0;
position: fixed;
}
#nav {
height: 50px;
left: 0;
overflow: hidden;
top: 0;
position: relative;
}
#nav li {
float:left;
position:relative;
z-index:10;
}
#nav li a {
background-repeat: no-repeat;
background-position: center top;
color: #fff;
display: inline;
float: left;
font-size: 14px;
height: 51px;
line-height: 40px;
padding: 0 10px;
position: relative;
text-decoration: none;
z-index: 20;
background-color: #005E20;
}
#nav li:first-child a {
background:url(file:///Macintosh%20HD/Users/davidscott/Downloads/example91/images/bg-menu.png) no-repeat left top;
padding-left:35px;
}
#nav li ul li:first-child a {
background-image:none;
padding-left:10px;
}
#nav li.pad {
background: url(file:///Macintosh%20HD/Users/davidscott/Downloads/example91/images/bg- menu.png) no-repeat right top;
display: inline;
height: 51px;
width: 35px;
}
#nav ul {
background-color: #FFFFFF;
height: auto;
padding: 10px 0;
position: absolute;
top: -115px;
width: 180px;
z-index: 1;
border-radius: 8px; /*some css3*/
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
transition: 0.8s ease-in-out;
box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);
-moz-box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);
-webkit-box-shadow: 2px 2px 3px rgba(0, 0, 0, 0.5);
-moz-transition: 0.8s ease-in-out;
-o-transition: 0.8s ease-in-out;
-webkit-transition: all 0.8s ease-in-out;
color: #005E20;
}
#nav ul li {
width:180px;
}
#nav ul li a {
background:transparent;
height:20px;
line-height:20px;
width:160px;
}
#nav:hover {
height:200px;
}
#nav li:hover ul {
-moz-transform:translate(0,161px); /*some css3*/
-o-transform:translate(0,161px);
-webkit-transform:translate(0,161px);
}
#nav a:hover,#nav li:hover > a {
color:#99ff33;
}
This changes the height of the nav on hover (pushing the rest of the page down):
#nav:hover {
height:200px;
}
This changes the color to green on hover:
#nav a:hover, #nav li:hover > a {
color:#99ff33;
}
Here's a rudimentary example without those hover definitions:
http://jsfiddle.net/w4uyX/
It's all in your CSS code (which seems a bit unorganized to me).
To deal with the menu pushing other content down, please find the selector #nav:hover where a larger height is set.
Then find the selector #nav a:hover,#nav li:hover > a. There is the setting for the different color, when you hover over the menu.
see my navbar and see the difference
http://codepen.io/leandroruel/pen/yrwKI

Hover on CSS menu only affects part of element?

I've made a css dropdown menu and I want each dropdown option to have a blue background when it is hovered on. However when I try this the background for the option will only be blue when the top half of it is hovered on. Here it is on jsfiddle. If you hover your mouse on the "products" option and then put the mouse under "plates" but above the gray horizontal line the background won't be blue. Can anybody help me? Thank you.
http://jsfiddle.net/hDWuJ/1/
HTML (Note this is a segment of my web page and so it does not have valid syntax)
<h1 id="title">Sample Text</h1>
<div id="HorzLineDiv"><hr></div>
<div id="MenuCenter">
<nav id="Menu" class="MenuBar">
<ul id="drop-nav">
<li>Home</li>
<li>Products <span id="arrowDown">&#9660</span>
<ul>
<li>Children's Stuff</li>
<li>Plates</li>
<li>Top Sellers</li>
</ul>
</li>
<li>Services <span id="arrowDown">&#9660</span>
<ul>
<li>Wash 'n' Fold</li>
<li>Blanket Making</li>
<li>Wedding Dress</li>
<li>Custom</li>
</ul>
</li>
</ul>
</nav>
</div>
CSS
body
{
background-color: #dfdfdf;
}
#title
{
text-align: center;
color: #07a8ca;
font-size:60pt;
margin: 0px;
padding: 0px;
text-shadow: 2px 2px 0px #888888;
}
h1
{
margin: 0px;
padding: 0px;
}
hr
{
height: 3px;
color: #07a8ca;
background: #07a8ca;
font-size: 0;
border: 0;
}
#HorzLineDiv
{
width: 95%;
margin: 2% 0% 3% 0%;
margin-left: auto ;
margin-right: auto ;
}
#Menu
{
width:100%;
}
#drop-nav
{
margin: 0 auto;
width: -webkit-fit-content;
width: -moz-fit-content;
width: fit-content;
}
ul
{
list-style: none;
padding: 0px;
margin: 0px;
}
ul li
{
display: block;
position: relative;
float: left;
display: inline;
padding: 12px 50px 8px 50px;
margin: 0px 5px 0px 5px;
border-left: 3px solid #07a8ca;
}
ul li:first-child
{
border-left: 0px;
}
li ul
{
display: none;
}
ul li a
{
display: block;
text-transform: uppercase;
text-decoration: none;
text-align:center;
color: #000;
font: 25px/1.1em "Kelly Slab","serif";
transition: color 0.4s ease 0s;
-moz-transition: color 0.4s ease 0s; /* Firefox 4 */
-webkit-transition: color 0.4s ease 0s; /* Safari and Chrome */
-o-transition: color 0.4s ease 0s; /* Opera */
}
ul li a:hover
{
color: #FF4D4D;
}
li:hover ul
{
display: block;
position: absolute;
}
li:hover li
{
float: none;
}
li:hover a
{
margin:0;
}
li:hover li a:hover
{
background: #21e8fa;
}
#drop-nav li ul li
{
border-top: 0px;
border-left: 0px;
}
#drop-nav ul li a
{
border-top: 3px solid #888;
padding: 13px 0px 13px 0px;
margin: -10px -8px;
text-align:center;
text-transform: none;
position:relative;
top: 13px;
color: #000;
}
#drop-nav ul
{
width:100%;
position:absolute;
right:-5px;
}
a
{
margin:0px;
padding:0px;
}
#arrowDown
{
font-size: 10pt;
vertical-align:text-bottom
}
The main issue is in your margins and padding, but this can be worked around by changing your ul li to display: block; instead of display: inline;.
Of course, this isn't a direct fix to the issue, and there still is an area at the bottom that doesn't work on hover, but it is much smaller than before. The proper way to go about fixing this is fixing your margins and padding.
Demo
UPDATE
Reading deeper into your code, I found the actual problem. It is not in margins or padding as I originally thought, but is a top property of 13px defined in #drop-nav ul li a. That top of 13px was creating a blank, inactive space in your list.
Get rid of that piece and it is working fine: DEMO