Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-14-2013, 01:00 PM   PM User | #1
williamvv
New to the CF scene

 
Join Date: Jan 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
williamvv is an unknown quantity at this point
Fixed position Dropdownbox menu

Dear all,

I have a problem on this site: http://www.frontmountain.com/royalflowers

I want a fixed position for the drop down menu.

Below you see the css code? I have tried several things, but it's not working.It'skeep shifting out of position.
#nav{
list-style:none;
text-decoration: none;
font-size: 14px;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
margin-bottom:10px;
/* Clear floats */
float:left;
width: 100%;
height: 30px;
margin-left: -30px;
/* Bring the nav above everything else--uncomment if needed.*/
position: relative;
z-index: 5;
}
#nav li{
float:left;
position: relative;
text-decoration: none;
}
#nav a{
display:block;
padding:5px;
color:#fff;
background:#5e5838;
width: 135px;

}
#nav a:hover{
color:#fff;
background:#322f20;
}

/*--- DROPDOWN ---*/
#nav ul{
background:#fff; /* Adding a background makes the dropdown work properly in IE7+. Make this as close to your page's background as possible (i.e. white page == white background). */
background:rgba(255,255,255,0); /* But! Let's make the background fully transparent where we can, we don't actually want to see it if we can help it... */
list-style:none;
position: absolute;
margin-left: -40px;
left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none */
}
#nav ul li{
padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */
float: none;
}
#nav ul a{
white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
#nav li:hover ul{ /* Display the dropdown on hover */
left:0; /* Bring back on-screen when needed */
}
#nav li:hover a{ /* These create persistent hover states, meaning the top-most link stays 'hovered' even when your cursor has moved down the list. */
background:#322f20;
text-decoration: none;
}
#nav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration:none;
}
#nav li:hover ul li a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
background:#333;
}


Can someone help me?

Thanks in advance.

Regards,

William
williamvv is offline   Reply With Quote
Old 01-14-2013, 04:49 PM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Hello williamvv,
There is a lot to look at here. I'll fix a couple things to get you started.

You're using a lot more absolute and relative positioning than you really need to. You also position each image, then position the div element containing it and re-use id's.

Those sidebar images can lose their containing divs and be positioned on their own. ul#nav doesn't need to be wrapped in a containing div either. Check out this article on divitis and how to avoid it.

...

You also need to know about the box model.
See the box model here. The box model says that whatever you put inside an element cannot be larger than that element. margin/padding/border all count when figuring width/height.

Your #wrapper is 1024px wide but you try to put 1100px wide ul#nav in it.

...

Make these changes to your CSS to get started -
Code:
@charset "utf-8";
/* CSS Document */
html, body {
  margin: 0;
  background: #fc6;
}
#wrapper {
	width: 1024px;
	margin-left: auto;
	margin-right: auto;
	position: relative;
  background: #0f0;
	/*float: left;*/
}

img#sidebarleft {
	position: absolute;
	left: -101px;
	top: 0;
	width: 100px;
	height: 700px;
	float: left;
}

img#sidebarright {
	position: absolute;
	right: -101px;
	top: 0;
	width: 100px;
	height: 700px;
}

.header {
	width: 1024px;
	height: 175px;
	/*position: relative;*/
}

.logo {
	position: absolute;
	top: 0;
	left: 10px;
	width: 175px;
	height: 175px;
}

.shadow {
	position: absolute;
	left: 181px;
	top: 498px;
	width: 1015px;
	height: 13px;
}

.boxone {
	position: absolute
	left: 181px;
	top: 510px;
	width: 480px;
	height: 150px;
}

/*#navigation {
	margin-left: 82px;
}*/

#nav{
	width: 1100px;
  padding: 0;
	list-style:none;
	font-size: 14px;
	font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
	/* Clear floats */
	/* Bring the nav above everything else--uncomment if needed.*/
	z-index: 5; 
}
See the links about validation below. You can learn a lot about coding just by fixing errors the validators find for you.




...
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:13 PM.


Advertisement
Log in to turn off these ads.