chrome nested navigation drop down hover issue - css

Chrome version: 41.0.2272.101 m
I have a list that is displayed horizontally, inside one of the list items I have some text and another list that is displayed vertically when the hover effect is active.
This works in IE and firefox without any issue & sometimes chrome.
When the developer tools plugin is open, it works, and when another tab is open it works.
I am pretty sure there is no issue with chrome, or my virtual server. I am confident that the issue is in my code.
<div id='unity'>
<div id='nav'>
<ul>
<li>
<a href='#'>Home</a>
</li>
<li>
<a href='#'>Team</a>
</li>
<li>
<a href='#'>About us</a>
</li>
<li id='nolink' class='drop'>
Service
<ul>
<li>
<a href='#'>Some awesome service</a>
</li>
<li>
<a href='#'>Some awesome service</a>
</li>
<li>
<a href='#'>Some awesome service</a>
</li>
<li>
<a href='#'>Some awesome service</a>
</li>
<li>
<a href='#'>Some awesome service</a>
</li>
</ul>
</li>
<li>
<a href='#'>Portfolio</a>
</li>
<li>
<a href='#'>Newsroom</a>
</li>
<li>
<a href='#'>Upcomming events</a>
</li>
<li>
<a href='#'>Contact us</a>
</li>
</ul>
</div>
html, body{
margin:0;
background:#ebebeb;
font-family: 'Roboto', sans-serif;
}
#unity{
width:1000px;
margin:0 auto;
background:white;
position:relative;
padding-top:35px;
position:relative;
}
#nav{
position:fixed;
top:0;
height:35px;
width:1000px;
background:rgba(255,255,255,0.9);
z-index:2;
}
#nav > ul{
margin:0;
padding:0;
font-size:0;
}
#nav > ul > li{
list-style-type: none;
display: inline-block;
font-size:12px;
}
#nav > ul > li{
}
#nav > ul > li > a, #nav > ul > li#nolink{
display:inline-block;
line-height: 35px;
height:35px;
padding:0 10px;
text-decoration: none;
color:#1c1c1c;
cursor:pointer;
}
#nav > ul > li > a:hover, #nav > ul > li#nolink:hover{
color:white;
background:#1c1c1c;
}
#nav > ul > li > ul > li{
display:block;
}
#nav > ul > li.drop > ul{
display:none;
background: #1c1c1c;
padding:0;
}
#nav > ul > li.drop:hover > ul{
display:block;
position:absolute;
margin-left:-10px;
border-radius: 1px;
}
#nav > ul > li.drop > ul > li{
text-align: center;
color:white;
line-height: 30px;
height:30px;
}
#nav > ul > li.drop > ul > li > a{
color:white;
display: block;
text-decoration: none;
padding:0 25px;
}
#nav > ul > li.drop > ul > li:hover > a{
color:#1c1c1c;
background:white;
}
#nav > ul > li.drop > ul > li, #nav > ul > li.drop > ul > li > a{
}
this bug also not happening in jsfiddle.
https://jsfiddle.net/575hbxzb/
youtube video:
https://www.youtube.com/watch?v=4XK5DprGr6k&feature=youtu.be

same issue here with a different chrome version 41.0.2272.118 m.
We use the same technique with our menu and in the last few month this issue was appear on chrome only.
If you open new tab or open debugging tools or resize the window the problem disappear.
I've found only a workaround: it is to enlarge the height of the top <li> so the child menu element and the <li> will overlap.
In this way the menu works but if the overlap area is too small and you move the mouse too fast the issue will appear again.
I think this is a chrome issue because some month ago we don't have any problem with our menu and all other browsers work well.
Hope this help.

I have the same problem and my workaround solution: add a margin-top:15px; to my header, is very ugly especily if the layout requires the menu at the first pixels but works for me until Google fix this bug.

Related

PureCSS and CSS menu dropdowns

I'm trying to use PureCSS, and get menudrop downs using CSS (rather than via either YUI or Jquery for portability reasons).
This is what I have so far:
http://jsfiddle.net/ket262p3/3/
<div class="pure-menu pure-menu-open pure-menu-horizontal">
<ul>
<li class="pure-dropdown">
Test1
<ul>
<li>Test2</li>
<li class="pure-menu-separator"></li>
<li>Test3</li>
</ul>
</li>
<li class="pure-dropdown">
Test1
<ul>
<li>Test2</li>
<li>Test3</li>
<li>Test4</li>
<li>Test5</li>
</ul>
</li>
</ul>
</div>
and:
#import url("http://yui.yahooapis.com/pure/0.5.0/pure-min.css");
.pure-menu-horizontal ul {
padding:0;
margin:0;
font-weight: bold;
width: 100%;
position: relative;
}
.pure-menu-horizontal ul li {
float:left;
position: relative;
display: block;
}
.pure-menu-horizontal ul li a {
display:block;
}
.pure-menu-horizontal ul ul {
display: block;
position: absolute;
top: 58px;
}
.pure-menu-horizontal ul li:hover > ul {
display: list-item;
left: auto;
}
I think the underlying problem may be some subtly in purecss that causes the second level menu not to display.
Ignore the extra classes - they represent earlier stages of getting this to work with YUI or JQuery.
You have to set the visibility of your subnavigation to visible.
.pure-menu-horizontal ul li:hover > ul {
display: list-item;
left: auto;
visibility: visible;
}
Example:
http://jsfiddle.net/ket262p3/6/
On further investigation it appears that a lot of the infrastructure for doing this is already built into PureCSS, but not documented very well. I replicate the solution below so that other people can find it.
The main solution is documented here: https://gist.github.com/maxbeatty/7829915
I have replicated in a jsfiddle: http://jsfiddle.net/0562cqd8/1/
The html is as follows
<!-- includes pure-min.css -->
<div class="pure-menu pure-menu-open pure-menu-horizontal">
Heading
<ul class="pure-menu-children">
<li class="pure-menu-can-have-children pure-menu-selected">
Cars
<ul>
<li>
Blue
</li>
<li>
Red
</li>
<li>
Green
</li>
</ul>
</li>
<li>
Trucks
</li>
</ul>
</div>
With CSS like this:
#import url("http://yui.yahooapis.com/pure/0.5.0/pure-min.css");
.pure-menu-can-have-children:hover {
background: #eee;
}
.pure-menu-can-have-children:hover ul {
top: 35px; /* height of menu li */
left: 0;
visibility: visible;
border: 1px solid #b7b7b7;
background: #fff;
}
Please try this css
.pure-menu ul
{
margin:0;
padding:0;
float:left;
width:100%;
}
.pure-menu ul > li
{
margin:0;
padding:0;
float:left;
list-style:none;
position:relative;}
.pure-menu ul > li >a
{
margin:0;
padding:0;
float:left;
padding:8px 4px;
text-decoration:none;
color:red;}
.pure-menu ul > li > ul
{
position:absolute;
top:100%;
left:0;
display:none;
width:200px;
}
.pure-menu ul > li > ul >li
{
width:100%;
}
.pure-menu ul > li > ul >li >a
{
padding:8px 20px;
background:red;
color:#fff;}
li.pure-dropdown:hover ul {
display:block;
}
change the color as per your requirement

CSS Multi-column Dropdown Menu not Behaving

I have a horizontal hover dropdown menu working almost flawlessly. The goal is if I hover over a Link, I will see a row of Sub Links. Each row has X amount of Child Links that should display down one column. However, currently the Child Links display across in a row not down the column under their Sub Link.
HTML:
<div class="menu">
<ul>
<li><a href='#'>Link 1</a>
<ul>
<li><a href='#'>Sub Link 1</a></li>
<ul>
<li><a href='#'>Sub Child Link 1</a></li>
<li><a href='#'>Sub Child Link 2</a></li>
<li><a href='#'>Sub Child Link 3</a></li>
</ul>
<li><a href='#'>Sub Link 2</a></li>
</ul>
</li>
<li><a href='#'>Link 2</a>
<ul>
<li><a href='#'>Sub Link 1</a></li>
<li><a href='#'>Sub Link 2</a></li>
<li><a href='#'>Sub Link 3</a></li>
<li><a href='#'>Sub Link 4</a></li>
</ul>
</li>
<li><a href='#'>Link 3</a>
<ul>
<li><a href='#'>Sub Link 1</a></li>
<li><a href='#'>Sub Link 2</a></li>
<li><a href='#'>Sub Link 3</a></li>
<li><a href='#'>Sub Link 4</a></li>
</ul>
</li>
</ul>
CSS:
.menu{
border:none;
border:0px;
margin:0px;
padding:0px;
border-bottom: 1px solid #ccc;
}
.menu ul{
background:#fff;
height:35px;
list-style:none;
margin:0;
padding:0;
}
.menu li{
float:left;
padding:0px;
}
.menu li a{
background:#fff;
color:#000;
display:block;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
text-transform: uppercase;
}
.menu li a:hover {
border-bottom: 1px solid #ff0000;
}
.menu li a:hover, .menu ul li:hover a{
background: #fff;
text-decoration:none;
}
.menu li ul{
background:#fff;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:400px;
z-index:200;
}
.menu li:hover ul{
display:block;
}
.menu li li {
background: #fff;
display:block;
float:left;
margin:0px;
padding:10px;
width:100px;
}
.menu li:hover li a{
background:none;
}
.menu li ul a{
display:block;
height:30px;
font-size:12px;
font-style:normal;
color: #999;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
text-transform: uppercase;
}
.menu li ul a:hover, .menu li ul li:hover a{
background:#fff;
border:0px;
text-decoration:none;
}
.menu p{
clear:left;
}
Okay, so the answer to your question comes in a few parts. All of it is available in this fiddle. Here goes.
The Markup
First, it's easier to deal with things if a sub-menu is nested in it's link's parent li. Also (side note) if your css fails for whatever reason, this will preserve the parent-child relationships. The new basic structure looks like this:
<div class="menu">
<ul>
<li>
<a href='#'>Link</a>
<ul>
<li>
<a href='#'>Child</a>
<ul>
<li><a href='#'>Grandchild</a></li>
</ul>
</li>
</ul>
<li>
</ul>
</div>
The Styles
In the fiddle, I have the styles separated into a couple parts, and I'll go over each.
The Reset
This is pretty straight forward. It just resets everything. It's not relevant to the solution, though, really, so I've left it out of the answer. It's in the fiddle if you need it.
The Flavor
In the fiddle, the flavor is just my own personal taste. It's mostly colors, but there is one important bit. We apply the padding to the a elements. This'll help things line up properly and will also provide as a side-effect a nice big clickable area.
.menu a {
display: block;
padding: 10px; /* padding on the a */
color: #000;
}
The Positioning
This is the real core of the answer. What we're doing is what you've already done, except we're un-setting the float on the third-level li. The short answer is just that line, honestly.
.menu li {
position: relative;
float: left;
}
.menu li ul { position: absolute; width: 400px; }
.menu li li ul { width: 120px; }
.menu li li li { float: none; } /* this lets columns happen again */
The Hover
To accomplish the hiding in a simpler way, we'll employ the use of the child selector (>). If you've never used it, Chris Coyier explains it very well, but basically it only gets immediate children. That way we can say any ul nested directly under an li should be displayed only if that li is being hovered. We do so like this:
.menu li > ul { display: none; }
.menu li:hover > ul { display: block; }
Edit: The MDN also has a great entry on the child selector. Check it out here.
The Demo
Again, the whole thing is demonstrated in a fiddle at http://jsfiddle.net/4tPcL/. Hope this helps!

Second level submenu CSS

I was hoping if you can help me with my little problem. I am just updating one of my developers style sheets. I am a beginner in CSS so I am having difficulties adding the second level submenu in it.
Here's the link DEMO PAGE
This is my HTML
<div id="sidebar"><i class="icon icon-home"> </i>Dashboard<ul style="display: block;">
<li class="active"><i class="icon icon-home"></i> <span>Dashboard</span> </li>
<li> <i class="icon icon-signal"></i> <span>Charts & graphs</span> </li>
<li><i class="icon icon-th"></i> <span>Tables</span></li>
<li><i class="icon icon-fullscreen"></i> <span>Full width</span></li>
<li class="submenu"> <i class="icon icon-th-list"></i> <span>API</span> <span class="label label-important">4</span>
<ul>
<li>
boom
<ul>
</ul>
</li>
<li>% of National Roads Paved</li>
<li>Process</li>
<li>Regional Profiles</li>
</ul>
</li>
</ul>
</div>
and this is my CSS
/* Top user navigation */
#sidebar{ width:100%; background:#252125; position:absolute; clear:both; top:62px;}
#sidebar > ul{ margin:0px; padding:0px; width:100%; display:block; z-index:999;}
/*Border right sidebar */
#sidebar > ul > li { list-style-type:none; float:left; display:block; margin:0px; border-right:1px solid #464652; position:relative; padding:10px; cursor:pointer}
/*Border right */
#sidebar > ul > li a{ padding:12px 0;}
#sidebar > ul > li:hover ul { display:block;}
/*#sidebar > ul > li:hover { background-color:#41bedd;} */
/*On hover menu */
#sidebar > ul > li:hover { background-color:#464652;}
/*On hover menu */
#sidebar > ul > li:hover a{ background:none;}
/*Modules color */
#sidebar > ul li ul { margin:0px; padding:0px; display:none; z-index:999; position:absolute; left:0px; top:40px; background:#464652; min-width:200px;}
/*Modules color */
#sidebar > ul li ul li { list-style-type:none; margin:0px; font-size:12px;line-height:30px; }
#sidebar > ul li ul li a { display:block; padding:5px 10px; color:#fff; text-decoration:none; font-weight:bold; }
/*Modules color on hover */
#sidebar > ul li ul li:hover a{ background-color:#5A5A69;}
/*Modules color on hover*/
#sidebar > ul li span { cursor:pointer; margin:0px 2px 0 5px; font-weight:bold; color:#fff; font-size:11px; }
#sidebar > ul li a i{ background-image: url("../img/glyphicons-halflings-white.png"); margin-top:4px; vertical-align: top;}
I know this post has been posted from different threads. I really cant understand them. Hope you understand. Thanks in advance.
First of all, in your sample HTML, you don't have any lis in your tertiary level. Put some in there.
As for your CSS, it's presently set up to handle the showing and hiding of UL's below the top level one on hover. We need to get more specific so that it excludes the 3rd level--as well as then get more specific to and add a second level hover style.
Where you have this:
#sidebar > ul > li:hover ul { display:block;}
Change it to this:
#sidebar > ul > li:hover > ul { display:block;}
The first will show ALL child ULs of the LI on hover. The latter will show only the direct child of the LI on hover.
Now we need to add a trigger for the 3rd level:
#sidebar > ul > li > ul > li:hover > ul { display:block; top: 0; left: 200px}
While we're at it, we included a new set of positioning so that it appears to the right of the current hover rather than below (which would cover up the second level navigation.
Working example: http://jsfiddle.net/wS9t3/

Main Menu Color Change

I am trying to target the header element of a drop down menu which I load in jfiddle here: http://jsfiddle.net/DZLtm/16/
I am trying to get it so when you roll over nav ul li it show black instead of red. Here are the lines that I would have thought would do it.
nav ul li {float: right; width: 172px; height: 35px; background-color: red;}
nav ul li:hover > ul {display: block; text-align: left; background-color: black;}
Here is the HTML:
<nav>
<ul>
<li>BUTTON IMAGE
<ul>
<li>Accreditation Client Login</li>
<li>Training Client Login</li>
<li>Training Registration</li>
<li>Guardian Tracking</li>
</ul>
</li>
</ul>
</nav>
Can someone please tell me why nav ul li:hover wont work and what is > ul have to do with it. When I remove it it breaks the menu. Thank you Frank!
Just add nav ul li:hover {
background-color:black;
}
http://jsfiddle.net/weissman258/DZLtm/17/

css dropdown menu glitch

i recently changed the design of this webpage but now my dropdown menu lists the "hidden" items vertically instead of horizontally even though i use the inline-block display option.
this is the html code from my menu:
<ul id="menu">
<li id="bordered">News</li>
<li id="bordered">About</li>
<li id="bordered">Research </li>
<li id="bordered">Artists
<ul>
<li id="bordered">1234 1234</li>
<li id="bordered">1234 1234</li>
</ul></li>
<li>Municipalities
<ul>
<li id="bordered">1234567</li>
<li id="bordered">1234 </li>
</ul></li>
<li>
<form id="searchbox" action=" " method=" ">
<input type="text" name="search" value="" />
<input type="submit" value="Search" />
</form>
</li>
</ul>
and this is the CSS:
/*header navigation menu*/
/*STYLING*/
#menu{
margin-top:2px;
font-size:0.8em;
list-style:none;
}
#menu li{
padding:1% 1.5% 1% 1.5%;
display:inline-block;
text-align:center;
vertical-align:middle;
}
#menu li a{
text-align:center;
vertical-align:middle;
font-weight:bold;
}
#bordered{
border-right:1px dotted #f9f9f3;
}
/*DROPDOWN*/
#menu li ul{
visibility:hidden;
position:absolute;
margin:1% 0 0 -2px;
border-top: 1px dotted #f9f9f3;
}
#menu li ul li{
float:left;
white-space:nowrap;
}
#menu li:hover ul, #menu li:active ul{
visibility:visible;
}
help would be very much appreciated :)
You should apply a float:left on #menu li instead of a display:inline-block
It fixes your problem, and it will work on IE7, when inline-block won't.
Also be careful with your bordered IDs. You should use classes.
Demo : JSFiddle
Try giving the #menu li ul a larger width:
#menu li ul{
visibility:hidden;
position:absolute;
border-top: 1px dotted #f9f9f3;
width: 10em;
}
and remove margin:1% 0 0 -2px;

Resources