Issue with a:hover on dropdown menu - css

I have a dropdown menu with two columns and I want the links inside the block that is the dropdown to change color when hovered over but when I add the style only the top level ul elements work and the entire block is active. I have been looking at this thing too long and can't figure out where I need to add the a:hover for the li.
Any idea where I need to place it so that the main links don't have a hover effect and the dropdown level do?
Full Screen
jsFiffle

This will make it work:
#top_nav li:hover > a { ... }
So, only the anchor directly within the hovered LI element "becomes active". When you hover the "projects" top-level menu item, its anchor will change color, but the anchors in the drop-down menu won't. When you then hover one of the anchors in that drop-down menu, it will change color, since its containing LI element has been hovered.

Related

Twitter Bootstrap navbar hover active with dropdowns

I'm sure my title is not the easiest to understand. I'll try and explain what I am trying to do.
If you go to this URL (http://buffalo.demo.libguides.com) and rollover over the global navigation (Find Library Materials, My Account, Get Help, etc) you'll see the hover is blue. But when you rollover the dropdown menu it goes back to grey. I want it to stay blue while hovering on the dropdown.
I had this working with an old version of Bootstrap, but I'm having trouble with this one. Any help would be appreciated.
Here is a URL with the old version that works. http://library.buffalo.edu
Try:
.content-block .navbar-nav > li:hover a {
color: #fff;
background-color: #062198;
}
Right now .content-block .navbar-nav > li > a:hover on line 1466 of style-gudes.css is controlling the background color of the navigation item. Since you're using a hover state on the anchor element which doesn't wrap the nested ul that forms the dropdown, it will not remain blue and revert to the default color once the cursor moves off that element.
Hook into the hover state of the li that wraps the dropdown ul. Target the anchor element when that li is being hovered, li:hover a. Now, whenever the the dropdown's parent li is hovered, the a will also be styled when that li is hovered.

Multilevel nav menu Hover issue

I have my nav working almost exactly how I want it. The only issue left I can't seem to figure out is this little arrow image I use on a subnav which indicates it contains another level subnav.
ul#css3menu ul span {
background-image: url("images/arrowsub.png");
padding-right: 28px;
}
ul#css3menu ul span:hover {
background-image: url("images/arrowsubhover.png");
padding-right: 28px;
}
When you hover over each subnav with an arrow, it loads a different color arrow image to maintain contrast with the background color that changes on hover.
Problem is when you hover over the next level subnav, the arrow switches back while the background color remains changed (as it should).
Why does the background color of the parent li not lose its hover rules but the arrow does?
you can see the behavior and code with this js fiddle
In your case it is better to assign the hover state on the main container of the list item rather than just target the specific element within your menu list item. In your case change your line 196 on js fiddle to .submenu li:hover span . Even if you move a level deep to access the child menu item, you are by default still hovering over the parent element.
Plus it is good practice not to use IDs when styling. IDs are usually reserved for Javascript.
It looks like the rule that affects the background color on hover is ul#css3menu ul li:hover>a
Since ul#css3menu ul li:hover detects hovering over any li element that is a child of ul#css3menu ul, and the 2nd-level submenu also consists of lis, the hover state for the 1st-level li is maintained when you hover over the 2nd-level li because the original rule is still in effect (since it is active when you hover over any child li, including the 2nd-level lis).
When ul#css3menu ul li:hover is true the CSS style is subsequently applied to the direct child a (rather than applied to the lis) to give you the full rule of ul#css3menu ul li:hover>a. This confused me too for a while because the detection happens separately from the application of the styles. Hope this helps.

add space between bootstrap dropdown toggle and dropdown-menu

I created a dropdown menu and made it drop on hover, but the problem is that I need to make a space between the toggle and the dropdown-menu as:
<http://jsfiddle.net/yabasha/nbbjm/1/>
When hover it displays the dropdown-menu but the problem when I want to select the menu it disappears.
Please advice,
Your problem is there is a gap between the li and the second level menu so when you are hovering, you are no longer on the li when you try to move to your submenu, which causes it to close.
You either need to move your submenu up, or extend the height of your li on hover to cover the space in between the li and the submenu
Adding the following styles to your fiddle seems to fix the problem:
.dropdown:hover {padding-bottom:20px;}
.dropdown-menu {top:auto;}
http://jsfiddle.net/nbbjm/8/

top menu li active when hover over submenu

I came across this site http://northerly.com.au/ and I am wondering how it is possible to make an top menu li active while hovering over it's submenu. In this case it seems like there is no js script to add active class. How it is done then? Thank you
In fact, that's not the top menu li which is active when you're hovering on the sub menu. There is a sibling SPAN before submenu element, as a result of hovering to sub menu, you are also hovering the container li element.
top li has two elements:
a SPAN has top menu title
a Sub Menu
Use a CSS selector like this:
li:hover span {/*span is active!*/ }
See a simple demo here.

PURE CSS DROP DOWN MENU - Unable to keep top <li> highlighted when hovering over sub-menu

I have a drop down menu in only CSS and no JAVASCRIPT and I'm having a problem keeping the top (main menu item) highlighted when I move the cursor over the sub menu items. You can see the menu here http://www.codedecks.com/cssnav.html.
If you hover over "Kids" and move your cursor down, as soon as your over "Girls" the top "Kids" looses the highlight.
Any suggestion would be greatly appreciated! Thanks in advance
Change #nav > li a:hover to #nav > li:hover a in your CSS.
Since you have the hidden second-level ul being shown when the top-level li is hovered, it makes sense to have the top-level a get the hover style at the same time. When you move your mouse over the second-level menu links, the a still looks active. li:hover applies even when you mouse over the child elements of the li, even if they're positioned so that they look like they're outside of the li's box.
For me it worked like this, without the >:
#navigation li:hover a {
background-color:#012A5E;
color:#F1F1F1;
}
You're currently setting the hover state on the A tag, you need to (also) set it on the LI tag. When you are over a child UL, you are no longer over the A, but you are still over the LI. Try this:
#nav li hover {
background-color:#F4F4F4;
color:#543056;

Resources