Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

932 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

12 Experts available now in Live!

Get 1:1 Help Now