White space before sub menu, what's wrong? - html

In this site I have a problem with the submenu that appears in the main navigation, there's a space before the list with the links I don't know why it changed but it appeared fine before, I really don't have an idea of what happened
#navigation {
float: right;
}
#navigation li {
float: left;
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.1em;
display: block;
}
#navigation li strong {
font-weight: 400;
border-right: #e8e8e8 1px solid;
display: block;
padding: 10px 20px;
}
#navigation li a {
padding: 20px 0;
color: #1c1c1c;
text-decoration: none;
display: block;
}
#navigation li:last-child strong {
border-right: none;
}
#navigation li span {
display: block;
color: #a09d9d;
text-transform: lowercase;
letter-spacing: 0.01em;
margin: 5px 0 0 0;
}
#navigation li a:hover span,
#navigation li:hover span,
#navigation li.current-menu-item a span {
color: #1c1c1c;
}
#navigation li li.current-menu-item,
#navigation li li.current_page_item,
#navigation li li:hover {
border-bottom: none;
}
#navigation li li,
#navigation li li:hover {
text-transform: none;
letter-spacing: 0;
border-bottom: #e8e8e8 1px solid;
}
#navigation li li a.sf-with-ul:after {
background: url(../images/arrows2.png) no-repeat;
width: 8px;
height: 8px;
content: '';
position: absolute;
top: 36%;
right: 1em;
}
#navigation li li a {
padding: 15px 20px;
background: #fff;
font-size: 13px;
}
#navigation li li a:hover {
background: #fafafa;
}
#navigation .current-menu-item,
#navigation .current_page_item,
#navigation li:hover {
border-bottom: 4px solid;
}
#navigation li ul {
box-shadow: 0 0 4px rgba(136, 136, 136, 0.6);
}

Seems like the top attribute value is just to high, change it to 93px
#navigation li:hover ul, #navigation li.sfHover ul {
left: 0.01em;
top: 93px;
z-index: 99;
}
Here is an another possible option from Bart:
#navigation li:hover ul, #navigation li.sfHover ul {
left: 0.01em;
top: 100%;
z-index: 99;
}

This seems to work too.
#navigation ul {
position: absolute;
width: 19em;
top: -999em;
margin-top: -39px;
}
In situations like this, i suggest you to use Firebug or Developer Tools integrated on your browser. A very little check using the Inspector tool (found in all developer tools and on Firebug) could have shown you how to resolve this problem very easily.

Or.......
Just remove:
top: -999em;
from:
#navigation ul {
position: absolute;
/* top: -999em; */
width: 19em;
}

Related

Hover menu not working properly for submenus

I have a simple vertical hover menu and even when I don't hover over any buttons but the cursor is a little to the right of it, it shows the submenu. When there isn't a submenu the main menu button starts to flicker. I am not entirely sure what is going on and why it is happening. Here is link to show what I mean.
EDIT: Thank you for your responses! Now I'm having a different/almost same problem. The menu doesn't freak out any more, but now there's a bar that sticks out of it and it is still opening the submenus without having to hover over the parent menu. Link to picture here.
Here's my HTML
<div id="divMenu">
<ul>
<li>Home1</li>
<li>Home2
<ul>
<li>Homed</li>
<li>Homee</li>
<li>Homef</li>
</ul></li>
<li>Home3
<ul>
<li>Homeg</li>
<li>Homeh</li>
<li>Homei</li>
</ul></li>
<li>Home4</li>
<li>Home5
<ul>
<li>Homej</li>
<li>Homek</li>
<li>Homel</li>
</ul></li>
<li>Home6</li>
</ul>
</div>
And my CSS
<style type="text/css">
#divMenu {
margin: 0px;
padding: 0px;
}
#divMenu ul {
margin: 0px;
padding: 5px 15px;
}
#divMenu li {
margin: 4px;
padding: 4px;
}
#divMenu li li {
margin: 0px;
padding: 0px;
}
#divMenu {
width: 150px;
height: 27px;
}
#divMenu ul {
line-height: 25px;
}
#divMenu li {
list-style: none;
position: relative;
background: #000;
}
#divMenu li li {
list-style: none;
position: relative;
background: #000;
left: 95px;
top: -30px;
}
#divMenu ul li a {
width: 150px;
height: 25px;
padding: 5px 5px;
display: inline-block;
letter-spacing: 6px;
text-decoration: none;
text-align: left;
font-family: Quicksand Light;
color: #ffffff;
border: 0px;
}
#divMenu ul ul {
position: absolute;
visibility: hidden;
top: 27px;
}
#divMenu ul li:hover ul {
visibility: visible;
}
#divMenu li:hover {
background-color: #fff;
}
#divMenu ul li:hover > a {
background-color: #fff;
color: #000;
}
#divMenu a:hover {
font-weight: normal;
color: #000;
}
</style>
Just remove width:0px from #divMenu ul li:hover > a and #divMenu a:hover from your style.
The problem of the block tripping is because of the width in the block underneath:
#divMenu ul li a {
width: 150px;
height: 25px;
padding: 5px 5px;
display: inline-block;
letter-spacing: 6px;
text-decoration: none;
text-align: left;
font-family: Quicksand Light;
color: #ffffff;
border: 0px;
}
Just remove that width and it should work.
It's due to the zero width you're applying to the links. You really don't need that.
#divMenu ul li:hover > a {
/*width: 0px;*/
background-color: #fff;
color: #000;
}
#divMenu a:hover {
/*width: 0px;*/
font-weight: normal;
color: #000;
}
#divMenu {
margin: 0px;
padding: 0px;
}
#divMenu ul {
margin: 0px;
padding: 5px 15px;
}
#divMenu li {
margin: 4px;
padding: 4px;
}
#divMenu li li {
margin: 0px;
padding: 0px;
}
#divMenu {
width: 150px;
height: 27px;
}
#divMenu ul {
line-height: 25px;
}
#divMenu li {
list-style: none;
position: relative;
background: #000;
}
#divMenu li li {
list-style: none;
position: relative;
background: #000;
left: 95px;
top: -30px;
}
#divMenu ul li a {
width: 150px;
height: 25px;
padding: 5px 5px;
display: inline-block;
letter-spacing: 6px;
text-decoration: none;
text-align: left;
font-family: Quicksand Light;
color: #ffffff;
border: 0px;
}
#divMenu ul ul {
position: absolute;
visibility: hidden;
top: 27px;
}
#divMenu ul li:hover ul {
visibility: visible;
}
#divMenu li:hover {
background-color: #fff;
}
#divMenu ul li:hover > a {
/*width: 0px;*/
background-color: #fff;
color: #000;
}
#divMenu a:hover {
/*width: 0px;*/
font-weight: normal;
color: #000;
}
<div id="divMenu">
<ul>
<li>Home1</li>
<li>Home2
<ul>
<li>Homed</li>
<li>Homee</li>
<li>Homef</li>
</ul></li>
<li>Home3
<ul>
<li>Homeg</li>
<li>Homeh</li>
<li>Homei</li>
</ul></li>
<li>Home4</li>
<li>Home5
<ul>
<li>Homej</li>
<li>Homek</li>
<li>Homel</li>
</ul></li>
<li>Home6</li>
</ul>
</div>

CSS – Getting rid of transparent box

After creating a navigation bar, I discovered a transparent box around it, which has some transparent features. Though it's not strikingly noticeable, I would still like to remove it. I've attached an image and the CSS code. I think the .menu tag is creating the transparent box, but I don't know how to remove it.
/* Navigation */
.clearfix {
width: 595px;
}
.clearfix:after {
display: block;
clear: both;
}
.menu-wrap {
width: 80px;
box-shadow: 0px 1px 3px rgba(0,0,0,0.2);
position: absolute;
top: 5.5%;
left: 55%;
}
.menu {
width: 100%;
margin: 0px;
right: 10px;
}
.menu li {
margin: 0px;
list-style: none;
font-family: "Source Sans Pro", Helvetica, Arial, sans-serif;
}
.menu a {
transition: all linear 0.15s;
color: #ffffff;
}
.menu li:hover > a, .menu .current-item > a {
text-decoration: none;
color: #000000;
}
.menu .arrow {
font-size: 11px;
line-height: 0%;
}
/* Top Level */
.menu > ul > li {
float: left;
display: inline-block;
position: relative;
font-size: 1em;
}
.menu > ul > li > a {
padding: 10px 30px;
display: inline-block;
text-decoration: none;
}
.menu > ul > li:hover > a, .menu > ul > .current-item > a {
background: #ffffff;
}
/* Bottom Level */
.sub-menu {
width: 140%;
padding: 5px 0px;
position: absolute;
top: 100%;
left: 0px;
z-index: -1;
opacity: 0;
transition: opacity linear 0.15s;
box-shadow: 0px 2px 3px rgba(0,0,0,0.2);
background: #ffffff;
}
.menu li:hover .sub-menu {
z-index: 1;
opacity: 1;
}
.sub-menu li {
display: block;
font-size: 1em;
}
.sub-menu li a {
padding: 10px 30px;
display: block;
color: #000000;
}
.sub-menu li a:hover, .sub-menu .current-item a {
background: #e0e0e0;
}
I played around with it a little and figured it out, but anyone else can feel free to comment if my answer isn't satisfactory.
The problem was actually caused by the .menu-wrap tag, and all I had to do to remove it was remove the box-shadow: 0px 1px 3px rgba(0,0,0,0.2); attribute I added to the code. It seems this transparent box had problems with the box-shadow property.

Dropdown Menus Disappear With Zero Margin

I know this question has been asked quite a few times, but I'm working on a Wordpress theme and I have the submenus styled exactly how I want them. However, they disappear upon hover. I have set all of my margin-tops to zero as stated on Stack previously but they still don't work properly.
My CSS for this top navigation is the following:
.top-nav {
background-color: #444;
min-height: 40px;
}
.top-nav ul {
margin-bottom: 0;
}
.top-nav li {
margin: 0 20px 0 0;
padding: 0;
float: left;
display: inline-block;
position: relative;
}
.top-nav li a {
color: #aaa;
font-size: 12px;
line-height: 40px;
}
.top-nav li a:hover, .top-nav li.current-menu-item a {
color: #fff;
background-color: #444;
}
.top-nav ul li ul.sub-menu {
display: none;
margin-top:0px;}
.top-nav ul li:hover > .sub-menu {
display: block;
position: absolute;
height: 0px;
margin-top:-5px;
overflow: visible;
margin-left:0px;}
.top-nav li.menu-item ul li {
display: block;
position:relative;
width: 100%;
float: left;
margin:0px;
padding:5px 0 5px 10px;
background-color:#444!important;
border-bottom: 1px solid #faf3bf;}
.top-nav ul li.menu-item ul li a {
width: inherit;
padding: 0;}
Any help would be greatly appreciated.
Had to add:
z-index: 1; to .top-nav li.menu-item ul li
The H3 of the title was covering the dropdown.

CSS won't change colour

Bought a template, and been working on this for the last couple of days. On my wits end now. I am trying to change the hover over main nav colour and current chosen page colour, to no avail. Please advice?
Code attached.
nav#main-nav {
z-index: 50;
display: block;
}
nav#main-nav ul {
position: relative;
z-index: 49;
margin: 0;
padding: 0;
list-style: none;
}
nav#main-nav ul li {
position: relative;
z-index: 45;
float: left;
margin: 0 0 0 20px;
padding: 0;
}
nav#main-nav > ul > li > a {
display: block;
font-family: Ubuntu;
font-size: 13px;
line-height: 40px;
color: #ffffff;
text-decoration: uppercase;
position: relative;
z-index: 45;
padding: 20px 0;
letter-spacing: 0.1em;
}
nav#main-nav > ul > li:hover {
z-index: 46;
color: #ffffff;
}
nav#main-nav > ul > li.current-menu-item,
nav#main-nav > ul > li.current-menu-ancestor {
color: #ffffff;
text-decoration: underline;
}
nav#main-nav ul li .sub-menu {
position: absolute;
top: 80px;
left: 0px;
width: 200px;
padding: 0;
display: none;
z-index: 47;
}
nav#main-nav ul .sub-menu li {
float: none;
border-top: 1px solid;
margin: 0;
}
nav#main-nav ul .sub-menu li:first-child {
border-top: none;
}
nav#main-nav ul .sub-menu li a {
color: #ffffff;
font-size: 12px;
line-height: 20px;
padding: 10px 20px;
display: block;
}
nav#main-nav ul .sub-menu li:hover {
background-color: #ffffff;
}
nav#main-nav ul .sub-menu li:hover a {
color: #ffffff;
}
nav#main-nav ul .sub-menu li.current-menu-item > a {
color: #ffffff;
text-decoration: underline;
}
nav#main-nav ul li ul li .sub-menu {
border-top: none;
position: absolute;
top: 0px;
left: 201px;
}
You have
nav#main-nav > ul > li:hover {
z-index: 46;
color: #ffffff;
}
The problem is that the anchor has other styles that override the code above. Then, use
nav#main-nav > ul > li:hover { z-index: 46; }
nav#main-nav > ul > li:hover > a {
color: #ffffff;
}

Drop-down menu dissappears when you hover over the subcategories

In this site I have a drop-down menu that disappears when I try to hover over the subcategories. I found a fix - to change the 'top:_' information so that it overlaps. That works great, but it looks pretty ugly. I currently have it with a gap (which I want), if I hover quick enough I can get it to say, but that isn't particularly user friendly. I read somewhere that the border might be giving it the problems?
CSS code
#navigation {
height: 37px;
background-image: url(../images/background/navbar.jpg);
background-repeat: repeat-x;
background-position: left top;
padding-bottom: 8px;
padding-top: 8px;
}
.nav-container {
}
#nav {
float: left;
height: 37px;
font-size: 13px;
z-index: 998;
}
/* ALL Levels */ /* Style consistent throughout all nav levels */
#nav li {
position: relative;
text-align: left;
border-left-width: 1px;
border-left-style: solid;
border-left-color: #fff;
margin-left: 10px;
height: 21px;
left: -1px;
}
#nav a,
#nav a:hover {
display: block;
line-height: 1.3em;
text-decoration: none;
}
#nav span {
display: block;
cursor: pointer;
white-space: nowrap;
}
#nav li ul span {
white-space: normal;
}
/* 0 Level */
#nav li {
float: left;
margin: 0;
}
#nav a {
float: left;
color: #fff;
line-height: 21px;
padding-top: 0px;
padding-right: 12px;
padding-bottom: 0px;
padding-left: 12px;
margin-bottom: 8px;
}
#nav li.over a,
#nav a:hover, #nav li a:hover {
/*color:#444; text-shadow: 0px 1px #fff;*/;
}
#nav a:hover {
line-height: 21px;
}
#nav li:hover a {
/*color: #444 !important; text-shadow: 0px 1px #fff; */;
}
#nav li.over, #nav li:hover {
/*color: #444 !important;*/;
}
#nav li.active {
}
#nav li.active a {
/*color: #444 !important;text-shadow: 0px 1px #fff !important; */;
}
#nav li.home {
background: none;
padding-right: 0;
}
#nav li.home a {
padding-left: 10px;
}
/* 1st Level */
#nav ul li,
#nav ul li.active,
#nav ul li.over {
float: none;
border: none;
background: none;
margin: 0;
padding: 0;
text-transform: none;
height: 20px;
}
#nav ul li.parent {
background: url(../images/bkg_nav_parent.gif) no-repeat 100% 50%;
}
#nav ul li.last {
padding-bottom: 0;
}
#nav ul li.active {
margin: 0;
border: 0;
background: none;
}
#nav ul a,
#nav ul a:hover {
float: none;
padding: 0;
background: none;
line-height: normal;
}
#nav ul li a {
font-weight: normal !important;
}
/* 2nd Level */
#nav ul {
position: absolute;
width: 15em;
top: 30px;
left: -10000px;
-moz-box-shadow: 3px 6px 8px 1px rgba(0, 0, 0, 0.3);
background-color: #FFF;
margin-right: 0px;
margin-left: 0px;
padding-top: 10px;
padding-right: 0px;
padding-bottom: 10px;
padding-left: 0px;
border: medium solid #087d74;
margin-bottom: 10px;
z-index: 10;
}
/* Show menu */
#nav li.over > ul {
left: 0px;
}
#nav li.over > ul li.over > ul {
left: 100px;
}
#nav li.over ul ul {
left: -10000px;
}
#nav li:hover > ul li:hover {
background-image: none !important;
}
#nav li.parent > ul li a {
background-image: none;
text-shadow: 0px 1px #fff !important;
}
#nav li.parent > ul li a:hover {
background-image: none;
text-shadow: 0px 1px #fff !important;
}
#nav ul li a {
color: #333 !important;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: #CCC;
margin-bottom: 20px;
padding-top: 10px;
height: 20px;
margin-top: 10px;
margin-right: 12px;
margin-left: 12px;
font-size: 12px;
}
#nav ul li.last a {
border-bottom: 0px;
}
#nav ul li a:hover {
color: #087d74 !important;
text-shadow: none !important;
margin-bottom: 15px;
padding-top: 10px;
}
/* 3rd+ Level */
#nav ul ul {
top: 0px;
border: 1px solid #bdbdbd;
}
#nav ul ul li a {
border-width: 1px 0px;
}
a.bord {
border-left-width: 1px;
border-left-style: solid;
border-left-color: #FFF;
}
HTML code
<div class="nav-container">
<ul id="nav">
<li class="level0 nav-1 parent" onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)">
<a href="http://www.ivcatalina.com/magento/index.php/furniture.html">
<span>
Furniture
</span>
</a>
<ul class="level0">
<li class="level1 nav-1-1 first">
<a href="http://www.ivcatalina.com/magento/index.php/furniture/living-room.html">
<span>
Living Room
</span>
</a>
</li>
<li class="level1 nav-1-2 last">
<a href="http://www.ivcatalina.com/magento/index.php/furniture/bedroom.html">
<span>
Bedroom
</span>
</a>
</li>
</ul>
</li>
<!-- Other menu items -->
</ul>
</div>
I made you an easy solution. You doesn't even have to change your JavaScript.
In your styles.css at the #nav span class add this line to your code: margin-bottom:10px;
So it will be:
#nav span {
display:block;
cursor:pointer;
white-space:nowrap;
margin-bottom:10px;
}