Solved

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

Posted on 2012-03-27
4
672 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now