Solved

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

Posted on 2012-03-27
4
678 Views
Last Modified: 2012-04-19
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
Comment
Question by:dthardy
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
David S. earned 500 total points
ID: 37774973
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
 
LVL 30

Expert Comment

by:LZ1
ID: 37776196
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
 

Author Comment

by:dthardy
ID: 37777565
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
 

Author Closing Comment

by:dthardy
ID: 37868245
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question