Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 699
  • Last Modified:

CSS & Javascript div positioning issue. Menubar dropdown anylinkmenu.js positioning does not appear directly under menu item.

My test page is http://www.estonish.com/default2.aspx.  

The problem is the dropdown menu appears to the left and far below the menu item.  The problem is the same in IE, Firefox, and Safari.  Hover over menu items "Clothing, Shoes, Computers, Electronics, At Home, Health" to see the issue.

I think the issue is associated to the #menubar being 'margin: 0 auto; width: 980;'.  If I move the <nav> menu out of a div the dropdown works fine but the menu is not properly positioned.

I think the anylinkmenu.js script is positioning everything from the left hand side of the menubar but I am unable to fix it.

The script is found at http://www.estonish.com/js/anylinkmenu.js

The css for anylink and the menubar is enclosed below.

/* navigation */
#menubar-container{float: left;position:relative;width: 100%;color: #000; margin:0;padding:0;}
#menubar{margin: 0 auto;width: 980px;}

.anylinkcss{left:0;top:0;position:absolute;visibility: hidden;z-index: 100;margin-top:5px;border:5px solid #bfade3;background-color:#fff;color:#03c;width: 200px;}

 .anylinkcss a, .anylinkcss a:link, .anylinkcss a:visited{width: 200px;display: block;border-right:0;border-bottom: 1px #ccc dotted;padding:4px 0px 4px 0px;text-indent: 12px;text-decoration: none;text-align:left;font-weight:400;font-size:12px;background:#fff;white-space:nowrap; box-shadow:none;color:#03c;text-shadow:none;}
 .anylinkcss a:hover{color:#fff;text-decoration:underline;background-color:#E9E9E9;}

Open in new window


The css file is here:
http://www.estonish.com/images/Skin2/style2.css

The nav bar css is in the header of http://www.estonish.com/default2.aspx

nav[role="navigation"] {
	display: table;
	width: 970px;
	vertical-align: middle;
	font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
	background: #888;
	background-image: -moz-linear-gradient(top, #888888 0%, #717171 50%, #5E5E5E 51%, #787878 100%);
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#888888), color-stop(50%,#717171), color-stop(51%,#5E5E5E), color-stop(100%,#787878));
	border-top: 1px solid #7b7b7b;
	border-bottom: 1px solid #565656;
	border-left: none;
	border-right: none;
	-webkit-border-radius: 4px;
	-moz-border-radius: 4px;
	-o-border-radius: 4px;
	border-radius: 4px;
	-webkit-box-shadow: 0 1px 1px rgba(0,0,0,.1);
	-moz-box-shadow: 0 1px 1px rgba(0,0,0,.1);
	box-shadow: 0 1px 1px rgba(0,0,0,.1);
	-webkit-transition: width .3s ease-in-out;
	-moz-transition: width .3s ease-in-out;
	-o-transition: width .3s ease-in-out;
	transition: width .3s ease-in-out;
	
}

nav[role="navigation"] ul {
	list-style-type: none;
	display: table-row;
}

nav[role="navigation"] li {
	display: table-cell;
	vertical-align: middle;
}

nav[role="navigation"] a {
	text-decoration: none;
	color: #fff;
	display: block;
	font-size: 12px;
	font-weight: 600;
	text-shadow: 
		0 -1px 0 rgba(30,30,30,.5), 
		0 2px 1px rgba(50,50,50,.5);
	border-right: 1px solid rgba(56,56,56, .5);
	-webkit-box-shadow: 
		inset -1px 0 0 rgba(225,225,225,.2), 
		inset 1px 0 0 rgba(225,225,225,.2);
	-moz-box-shadow: 
		inset -1px 0 0 rgba(225,225,225,.2), 
		inset 1px 0 0 rgba(225,225,225,.2);
	box-shadow: 
		inset -1px 0 0 rgba(225,225,225,.2),
		inset 1px 0 0 rgba(225,225,225,.2);
	padding: 0 30px;
	line-height: 34px;
}

nav[role="navigation"] a:hover {
	background: rgba(11,11,11, .55);
	-webkit-box-shadow: inset 0 0 15px rgba(180,180,180,.3);
	-moz-box-shadow: inset 0 0 15px rgba(180,180,180,.3);
	box-shadow: inset 0 0 15px rgba(180,180,180,.3);
}

nav[role="navigation"] a:active {
	background: rgba(35,35,35,.6);
	-webkit-box-shadow: inset 0 2px 5px rgba(0,0,0,.7);
	-mox-box-shadow: inset 0 2px 5px rgba(0,0,0,.7);
	box-shadow: inset 0 2px 5px rgba(0,0,0,.7);
}

nav[role="navigation"] li:first-child {
	
	border-top-left-radius: 4px;
	border-bottom-left-radius: 4px;
	
}

nav[role="navigation"]>a.active {
	background: rgba(71,71,71, .9);
	-webkit-box-shadow: 
		inset -10px 0 25px rgba(0,0,0,.2),
		inset 10px 0 20px rgba(0,0,0,.2),
		inset 0px 0px 20px rgba(0,0,0,.2),
		inset 0px 10px 20px rgba(0,0,0,.2);
	-moz-box-shadow: 
		inset -10px 0 25px rgba(0,0,0,.2),
		inset 10px 0 20px rgba(0,0,0,.2),
		inset 0px 0px 20px rgba(0,0,0,.2),
		inset 0px 10px 20px rgba(0,0,0,.2);
	box-shadow: 
		inset -10px 0 25px rgba(0,0,0,.2),
		inset 10px 0 20px rgba(0,0,0,.2),
		inset 0px 0px 20px rgba(0,0,0,.2),
		inset 0px 10px 20px rgba(0,0,0,.2);
}

nav[role="navigation"]>li:first-child a.skm {background:url("../images/Skin2/home.png") center no-repeat ; text-indent: 100%; color:transparent;text-shadow: none; white-space: nowrap; overflow: hidden; width: 22px; height: 34px;}


nav[role="navigation"]>li.last_container { border-right:0; }
/* Fade in animation (Webkit only) */
@-webkit-keyframes showMenu {
    from { opacity: 0; top:-20px; }
    to   { opacity: 1; }
}

nav[role="navigation"] {
     -webkit-animation: showMenu 1s; position:relative;
}

Open in new window


Let me know if you need anything else to help solve the problem.
0
dthardy
Asked:
dthardy
  • 2
1 Solution
 
David S.Commented:
That menu script is making an incorrect assumption about your styles. It is also very old. Therefore, I recommend that you use the Superfish menu script instead. (And you may want to upgrade the version of jQuery you're using.)

P.S. Are you aware that your page contains HTML errors?
http://validator.w3.org/
0
 
LZ1Commented:
I have to agree with Kravimir.   The structure for your menu isn't even semantic, nor correct for this type of application.  

I second Superfish.
0
 
dthardyAuthor Commented:
Okay.  I'll look at Superfish this evening.

Yes I am aware their are html errors.  This is just a testing page and some of the elements are incomplete.
0
 
dthardyAuthor Commented:
I did not use Superfish but instead searched and found a css solution.  My question was not answered but I did use the suggestion of Superfish but did follow the suggestion of finding another script or method.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now