CSS Sub-menu item will not let me hover it - css

I am trying to do a menu in CSS with a Unordered List UL, I have it almost working correctly.
I am having a little trouble, if you run the code below or look at it on the JSFiddle link here http://jsfiddle.net/hgBDV/1/ You will see there is a Horizontal menu, when you hove the 2nd to last item labeled "More" there is a Sub-menu.
That sub-menu is what I need help with, right now when you hover the "Menu" list item, the sub-menu becomes visible on the screen however you are unable to hover of the sub-menu.
Please help me correct this issue
<div id="nav-wrapper">
<ul>
<li>Link</li>
<li>Link 2</li>
<li>Link 3</li>
<li>Link 4</li>
<li>Link 5</li>
<li>More
<ul>
<li>Sub Link 1</li>
<li>Sub Link 2</li>
<li>Sub Link 3</li>
<li>Sub Link 4</li>
<li>Sub Link 5</li>
</ul>
</li>
<li>Link 7</li>
</ul>
</div>
css
<style type="text/css">
#nav-wrapper ul {
width: 700px;
float: right;
margin: 0;
list-style-type: none;
}
#nav-wrapper ul li {
vertical-align: middle;
display: inline;
margin: 0;
color: black;
list-style-type: none;
}
#nav-wrapper ul li a {
text-decoration: none;
white-space: nowrap;
line-height: 45px;
font-size: 13px;
color: #666;
padding: 5px 15px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
#nav-wrapper ul li a:hover {
color: #fff;
background-color: #4caef2;
}
#nav-wrapper ul li a:visited {
color: #666;
}
/* Hide Sub-menus */
#nav-wrapper ul ul,
#nav-wrapper ul li:hover ul ul,
#nav-wrapper ul ul li:hover ul ul{
display: none;
}
/* SHOW Sub-menus on HOVER */
#nav-wrapper ul li:hover ul,
#nav-wrapper ul ul li:hover ul,
#nav-wrapper ul ul ul li:hover ul{
display: block;
margin:0;
padding:0px 2px 2px 0px;
border-color:#AAAAAA;
border:1px;
border-style:solid;
}
</style>

http://jsfiddle.net/hgBDV/2/
You are having trouble because the line-height is 45px but your text-size is 13px. The sub-menu shows up when you hover over the 'more' link, but when you move your mouse outside of the bounds of the 'more' link, the sub-menu is no longer displayed. While you have set the margin to 0px, the line-height is allowing for a 20px gap. In my 'fix', i have set the line height to 0px. Google "css suckerfish" for an already invented wheel.

deleted the thing line-height
#nav-wrapper ul {
width: 700px;
float: right;
margin: 0;
list-style-type: none;
}
#nav-wrapper ul li {
vertical-align: middle;
display:inline;
margin: 0 0 0 0;
color: black;
list-style-type: none;
}
#nav-wrapper ul li a {
text-decoration: none;
white-space: nowrap;
font-size: 13px;
color: #666;
padding: 5px 15px 5px 15px;
margin: 5px 0px 0px 10px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
}
#nav-wrapper ul li a:hover {
color: #fff;
background-color: #4caef2;
}
#nav-wrapper ul li a:visited {
color: #666;
}
/* Hide Sub-menus */
#nav-wrapper ul ul {
display: none;
}
/* SHOW Sub-menus on HOVER */
#nav-wrapper ul li:hover ul{
display:block;
margin:3px 0 0 0; /* if you change top value here thing will screw up */
padding:0px 2px 2px 0px;
border-color:#AAAAAA;
border:1px;
border-style:solid;
}

Related

Hover Submenu Getting Cut Off

I'm working on this project: http://www.livingthelighterlife.com/
The top navigation bar (Home, About, Contact, Work With Me) is giving me some difficulty. I have a hover submenu right now under the "About" section, but it is appearing under the header, for lack of a better explaination. I've messed with the z-index and that doesn't seem to be doing anything. Not quite sure what else to try.
Thanks in advance!
#top-navigation {
float: left;
}
#top-navigation ul {
list-style: none;
position: relative;
}
#top-navigation ul a {
display: block;
color: #ffffff;
text-decoration: none;
}
#top-navigation ul li {
position: relative;
float:left;
margin: 0px 10px;
}
#top-navigation ul li:hover {
background: #f6f6f6;
}
#top-navigation ul ul {
display: none;
position: absolute;
top: 100%;
left: 0;
background: #ffffff;
padding: 0;
}
#top-navigation ul ul li {
float:none;
width:200px
}
#top-navigation ul ul a {
line-height: 120%;
padding: 10px 15px;
}
#top-navigation ul ul ul {
top: 0;
left: 100%;
}
#top-navigation ul li:hover > ul {
display: block;
}
<div class="before-header"><section id="text-5" class="widget widget_text"><div class="widget-wrap"> <div class="textwidget"><nav id="top-navigation">
<ul>
<li>
Home
</li>
<li>
About
<ul>
<li>Sub Menu 1</li>
<li>Sub Menu 2</li>
<li>Sub Menu 3</li>
</ul>
</li>
<li>
Contact
</li>
<li>
Work With Me
</li>
</ul>
</nav></div>
</div></section>
</div>
In header section in this class .before-header you are using overflow hidden. That's why your submenu doesn't show. You can not use overflow hidden where you want to use submenu. Just remove overflow hidden.
check the header div with class .before-header, Do the following change:
.before-header {
z-index: 500;
background: #6d5d68;
clear: both;
/* overflow: hidden; */
padding: 7px 0;
text-align: center;
font-family: 'Arquitecta-Medium', 'Source Sans Pro', Helvetica, Arial, sans-serif;
font-size: 12px;
color: #ffffff;
letter-spacing: 1px;
text-transform: uppercase;
}

Dropdown Menu shifted to the right

I have a dropdown menu that is working well except for one minor bug that I cannot solve.
The first dropdown menu item appears normally. However, the second dropdown menu item is shifted slightly to the right. I am guessing that the margin-right that I set to the link caused the dropdown menu to shift slightly to the right. If that is the case, what can I do to go around the problem?
It's a simple nav menu that sets the position of the dropmenu item to absolute, and is hidden by the parent element's overflow:hidden feature. On hover, the dropdown menu is brought into view with overflow:visible.
The live site is here -> nav menu
CSS
#mainMenu {
position: relative;
}
#mainMenu ul {
list-style: none;
float: right;
background-color: #FFFFFF;
}
#mainMenu ul li {
position: relative;
display: inline;
float: left;
/*padding-right: 1.5em;*/
font-size: 1.2em;
zoom:1;
overflow: hidden;
}
#mainMenu>ul>li {
line-height: 2em;
}
#mainMenu ul li:hover {
overflow: visible;
}
#mainMenu ul li a {
float: left;
text-decoration: none;
color: black;
padding: 0 1em;
}
#mainMenu>ul>li:last-child a {
padding:0.4em 1em 0.4em 1em;
border-radius:4px;
background-color: #00b200;
color: #FFFFFF;
}
#mainMenu ul li a:hover{
text-decoration: none;
color: rgb(42, 160, 239);
}
#mainMenu ul ul{
position: absolute;
top: 2em;
left: 60%;
width: 10em;
margin-left: -3em;
height: auto;
border: solid #CCC;
border-width: 0 1px 1px;
}
#mainMenu ul ul:first-child{
padding-top: 2em;
}
#mainMenu ul ul li,
#mainMenu ul ul a {
display:block;
float:none;
border:0;
box-shadow:none;
text-align:center;
font-size: 1em;
padding: 0.4em;
text-align: left;
}
#mainMenu ul ul li:first-child {
border-top:1px solid rgb(72, 147, 196);
}
#mainMenu ul ul li {
border-top: 1px solid #e9e9e9;
}
#mainMenu a:active,
#mainMenu a:focus,
#mainMenu a:hover {
background:#F2F6FA;
color:#333;
}
HTML
<div id="nav-row">
<h1>
<a href="\">
Corporate Site
<span></span>
</a>
</h1>
<div id="mainMenu">
<ul>
<li>About
<ul>
<li class="company">Company Profile</li><li class="team">
The Team</li><li class="linsux">
Pricing Packages</li>
</ul></li>
<li>Services
<ul>
<li class="webDesign">Websites</li><li class="Emails">
Landing Pages</li><li class="Logos">
Logos</li>
</ul></li>
</li>
<li>Case Studies</li><li>
Blog</li><li>
Contact</li><li>
Free Web Analysis</li>
</ul>
</div>
</div>
It because you use to indent the submenu % of parent width which isn't the same. margin-left: -3em is a constant.
Use, for example:
left: -10px; /* I see the first submenu cca. 10px before the parent LI */
margin-left: 0;
Not sure why you indent by 60% and the move the submenu back using -3em.
try the following :
#mainMenu ul ul {
left: 39% !important;
}
Or
#mainMenu ul ul {
left: 0;
margin-left: 0;
}

Css Vertical Menu Fly Out

The submenu of the vertical dropdown portion of my .css-driven menu has an issue. In the jsfiddle example, high lighting 'Bedroom Furniture' under 'Products' displays 'Bunk Beds'. While Bunk Beds' is being displayed, the menu option below (Home Office) isn't selectable (actually, it CAN be selected if the mouse is moved to the far right of Home Office). I've exhausted all of my ideas and any help would be appreciated.
I think the issue is in the 'second level vertical drop down' section of the CSS (CSS snippet...please see jsfiddle example)
.rmenu li ul li:hover ul li a {
/*padding: 0px 0px 0px 33px;*/
padding: 0px 0px 0px 5px;
background: #e8dec7;
/*background color for submenu hovered text*/
color: #51db29;
/* this is the color of the sub-sub menu text. I made the color (#51db29) 'unusual' as an example. Should be changed to something less jarring (of course) */
word-wrap: break-word;
min-width:100px;
position: relative;
left: 175px;
top: -35px;
/* display 3rd level to the right*/
}
/* -- Appearance of second vertical dropdown menu hovered (submenu of first level vertical menu) -- */
.rmenu li ul li:hover ul li:hover a {
color: #000000;
/*hovered text color*/
min-width:100px;
}
/* ----
see the js fiddle : http://jsfiddle.net/mf3y6Lj6/1/
try this :
<div id="header">
<div id="nav">
<ul>
<li>
Menu1
<ul>
<li>submenu
<ul>
<li>sub sub menu</li>
<li>sub sub menu</li>
<li>sub sub menu</li>
<li>sub sub menu</li>
</ul>
</li>
<li>submenu</li>
<li>submenu</li>
<li>submenu</li>
<li>submenu</li>
</ul>
</li>
<li>
Menu2
</li>
<li>
Menu3
<ul>
<li>submenu</li>
<li>submenu</li>
<li>submenu
<ul>
<li>sub sub menu</li>
<li>sub sub menu</li>
<li>sub sub menu</li>
<li>sub sub menu</li>
</ul>
</li>
</ul>
</li>
<li>
Menu4
</li>
<li>
Menu5
</li>
</ul>
</div>
</div>
ul, li {
margin:0; padding:0; list-style:none; text-decoration:none; color:#fff}
a { text-decoration:none;
color:#fff}
#nav ul {
width:100%;}
#nav ul li {
float:left; padding:0 15px; line-height:40px;}
body {
overflow: hidden;
}
#header {
background: none repeat scroll 0 0 #808080;
box-shadow: 1px 2px 3px #000;
float: left;
height: 50px;
width: 87%;
}
#nav ul li {
float: left;
line-height: 51px;
padding: 0 15px;
}
#nav ul > li:hover {
background-color: #000;
}
#nav ul li > ul {
background-color: #000;
display: none;
position: absolute;
top: 59px;
width: 150px;
}
#nav ul li:hover > ul {
display:block}
#nav ul li > ul > li {
background: none repeat scroll 0 0 #999;
border-bottom: 1px solid;
margin: 0;
padding: 0;
position: relative;
text-align: center;
text-transform: capitalize;
width: 100%;
}
#nav ul li > ul > li > ul {
background: none repeat scroll 0 0 pink;
display: none;
left: 150px;
position: absolute;
text-align: center;
top: 0;
}
#nav ul li > ul > li:hover ul {
display:block}
#nav ul li > ul > li > ul > li {
background: none repeat scroll 0 0 pink;
color: #000;
margin: 0;
padding: 0;
position: relative;
width: 100%;
}

submenu not working in dropdown menu css

I have made a dropdown menu with rollover image. The rollover image almost works (Benedict Cumberbatch is meant to turn into an otter) and a submenu to drop down (which at the moment doesn't appear).
What have I done wrong? Here is the JSfiddle
The HTML >>
<ul id="nav">
<li><img src="http://static.tumblr.com/bw1wxme/Lgsmzv53i/rollover-1.jpg">
<ul>
<li>1.2.1.1. Sub-Level-3</li>
<li>1.2.1.2. Sub-Level-3</li>
<li>1.2.1.3. Sub-Level-3</li>
<li>1.2.1.4. Sub-Level-3</li>
</ul>
</li>
The CSS >>
#nav {
width: 100%;
float: left;
margin: 0 0 3em 0;
padding: 0;
list-style: none;
opacity:1;
}
#nav li {
float: left; }
#nav li a {
display: block;
padding: 8px 15px;
text-decoration: none;
font-weight: bold;
color: #069;
}
#nav li a:hover {
color: #c00;
background-color: #fff;
}
#nav ul {
list-style-type:none;
display:none;
}
#nav .about:hover {background-image:url('http://static.tumblr.com/bw1wxme/RjMmzv543/rollover-2.jpg');}
You should add this to your css:
#nav li:hover ul {display:block;}
To show it when hover
Updated JsFiddle

CSS style not working in submenu

I've created a css menu and submenu using style sheet.
the code and style sheet is as follows
<style type="text/css">
*{
padding:0px;
margin:0px;
}
#navdiv
{
border: 1px solid black;
text-align:center;
background:#FF0000;
border-radius: 10px;
width: 50%;
margin: 10px;
}
nav ul ul
{
display:none;
width:auto;
}
nav ul li:hover >ul
{
display:block;
}
nav ul
{
background: #ff0000;
padding: 0px;
border-radius: 0px;
list-style: none;
position: relative;
display: inline-table;
font-size: 12px;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
text-transform:uppercase;
}
nav ul li
{
float:left;
background: #ff0000;
border: 0px solid black;
}
nav ul li:hover
{
background: #DDDDDD;
}
nav ul li a
{
display:block;
padding: 10px 25px;
text-decoration: none;
color:#FFFFFF;
}
nav ul li:hover a
{
color:#000000;
}
nav ul ul
{
background: #ff0000;
position: absolute; top: 100%;
}
nav ul ul li
{
float: none;
border: 1px solid #000000;
position: relative;
color:#FFFFFF;
}
nav ul ul li a
{
background-color: #FFFFFF;
color: #FFFFFF;
}
nav ul ul li a:hover
{
background: #000000;
color:#FFFFFF;
}
nav ul ul ul
{
position: absolute; left: 100%; top:0;
}
</style>
<div id="navdiv">
<nav>
<ul>
<li>Home</li>
<li>Tutorials
<ul>
<li>Photoshop</li>
<li>Illustrator</li>
<li>Web Design
<ul>
<li>HTML</li>
<li>CSS</li>
</ul>
</li>
</ul>
</li>
<li>Articles
<ul>
<li>Web Design</li>
<li>User Experience</li>
</ul>
</li>
<li>Inspiration</li>
</ul>
</nav>
</div>
I want to change the color of submenu (i.e Photoshop, illustrator, web design in my example)
I'm able to change the background color using
css
nav ul ul li a
{
background-color: #FFFFFF;
color: #FFFFFF;
}
But i'm not getting why the font color is not getting change?
Please help me with the problem
try to Add a:visited instead of just a to the CSS selector.
nav ul ul li a, nav ul ul li a:visited
Just add a:visited instead of anchor tag
eg:nav ul ul li a, nav ul ul li a:visited
The easiest way to get this is as below:
nav ul ul ul li,
nav ul ul li
{
background-color: #FFFFFF;
color: #FFFFFF;
}
Try this it will resolve your issue, please share I can help you with more options.

Resources