I am new around here, and new to building my own site. I have an issue that I am hoping has an easy solution - I would really appreciate it if someone could point me in the right direction.
So, I am trying to put together a drop down menu, and I want the menu items to be spaced unequally. To make it easier to explain below is a graphical view of what I want - I just can’t seem to overcome the fact that anytime I space out the menu the gaps are equal - not what I want. Please be aware, I am a COMPLETE novice.
/*------------------------------------*\\
NAV
\\*------------------------------------*/
#nav{
float:left;
width:100%;
list-style:none;
font-weight:bold;
margin-bottom:10px;
}
#nav li{
float:left;
margin-right:10px;
position:relative;
display:block;
}
#nav li a{
display:block;
padding:5px;
color:#fff;
background:#333;
text-decoration:none;
text-shadow:1px 1px 1px rgba(0,0,0,0.75); /* Text shadow to lift it a little */
-moz-border-radius:2px;
-webkit-border-radius:2px;
border-radius:2px;
}
#nav li a:hover{
color:#fff;
background:#6b0c36; /* Solid colour fall-back */
background:rgba(107,12,54,0.75); /* It'll look nice semi-transparent */
text-decoration:underline;
}
/*--- DROPDOWN ---*/
#nav ul{
list-style:none;
position:absolute;
left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */
opacity:0; /* Set initial state to transparent */
-webkit-transition:0.25s linear opacity; /* Make the dropdown fade-in in Webkit */
}
#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 */
display:block;
}
#nav li:hover ul{ /* Display the dropdown on hover */
left:0; /* Bring back on-screen when needed */
opacity:1; /* Fade to opaque */
}
#nav li:hover a{ /* Set styles for top level when dropdown is hovered */
background:#6b0c36; /* Solid colour fall-back */
background:rgba(107,12,54,0.75); /* It'll look nice semi-transparent */
text-decoration:underline;
}
#nav li:hover ul a{ /* Override some top level styles when dropdown is hovered */
text-decoration:none;
-webkit-transition:-webkit-transform 0.075s linear;
}
#nav li:hover ul li a:hover{ /* Set styles for dropdown when items are hovered */
background:#333; /* Solid colour fall-back */
background:rgba(51,51,51,0.75); /* It'll look nice semi-transparent */
text-decoration:underline;
-moz-transform:scale(1.05);
-webkit-transform:scale(1.05);
}
Yes, spacing out the menu headers and matching the drop downs below.
Ah, alas the code is not mine - it was a free menu posted online (credit mentioned in my original post) It’s mostly Greek to me!
I have attached a mock up of my menu plan - the top line is just text (not clickable) and the second line is the menu headers. Because of the different word widths in line one, I need unequal spacing in the menus below.
The advice that you gentlemen have given is not crystal clear to me right now, but it tells me what I need to learn about to achieve what I want, and I do want to learn a lot more - I am very grateful to you both.
Thanks!!!
Hugh
Here is the mock up. You can see why I need to move the menu around.
The code to cancel out the margin and padding (below), I have dropped into the first line of the CSS on it’s own. Is that ok there, or should it be nested somewhere else?
#nav, #nav ul{margin:0;padding:0}
In the CSS I have added lines of code to move the menus around. This is how I have done it - same question really, should this be nested somewhere?
Again, thanks for the stellar assistance. Hope the weather in the UK is good, (I’m from Edinburgh) Michigan has been cold as hell recently, with tons of snow!
Apologies if your post above looks a little strange as I clicked the wrong button by mistake and made an edit
The code to cancel out the margin and padding (below), I have dropped into the first line of the CSS on it’s own. Is that ok there, or should it be nested somewhere else?
#nav, #nav ul{margin:0;padding:0}
That’s fine as it is.
However, I would actually put it the stylesheet as the first rule of your navigation styles because it really is the starting point. I like to keep this logical so you start with the ul and then move onto the list element and inner elements etc.
In the CSS I have added lines of code to move the menus around. This is how I have done it - same question really, should this be nested somewhere?
That way you keep the relevant styles affecting top level list items together which makes things easier to manage later on.
Remember that with negative margins may cause things to overlap while with positive margins you just push things away. It may be that the negative margin just overlaps a positive margin on the element before but it’s a subtle difference.
Again, thanks for the stellar assistance. Hope the weather in the UK is good, (I’m from Edinburgh) Michigan has been cold as hell recently, with tons of snow!
You’re welcome
The weather’s not too bad here - finally stopped raining for a couple of days
What I am trying to do is have the top word (Galleries) trigger the menu with the three options below, without itself being a link. My problem is that only the first option (Wedding One) shows.
Sorry to be a pain, am I missing something really obvious???
In the style.css document I am close to getting the styling that I want. This part seems to be just fine.
/*------------------------------------*\\
NAV
\\*------------------------------------*/
#nav, #nav ul{margin:0;padding:0}
#nav{
position :absolute;
width :100%;
display :block;
font-size : 10pt;
text-align :center;
font-family :Tahoma, Georgia, Times, serif;
margin :60px 0 10px 190px;
z-index :99999;
}
#nav li{
float :left;
margin-right :0px;
position :absolute;
display :block;
}
/* Adjusts the distance between each menu item horizontally */
#nav li.galleries {margin-left :0px}
#nav li.clientaccess {margin-left :115px}
#nav li.whoweare {margin-left :231px}
#nav li.information {margin-left :367px}
#nav li.emailus {margin-left :505px}
#nav li.latest {margin-left :607px}
#nav li a{
display:block;
padding:5px;
color:#807e7e;
text-decoration:none;
text-shadow:1px 1px 1px #efe9e9; /* Text shadow to lift it a little */
-moz-border-radius:2px;
-webkit-border-radius:2px;
border-radius:2px;
}
#nav li a:hover{
color:#000;
background:#6b0c36; /* Solid colour fall-back */
background:rgba(107,12,54,0.75); /* It'll look nice semi-transparent */
text-decoration:none;
}
/*--- DROPDOWN ---*/
#nav ul{
list-style:none;
position:absolute;
left:-9999px; /* Hide off-screen when not needed (this is more accessible than display:none;) */
opacity:0; /* Set initial state to transparent */
-webkit-transition:0.25s linear opacity; /* Make the dropdown fade-in in Webkit */
}
#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 */
display:block;
}
#nav li:hover ul{ /* Display the dropdown on hover */
left:0; /* Bring back on-screen when needed */
opacity:1; /* Fade to opaque */
}
#nav li:hover a{ /* Set styles for top level when dropdown is hovered */
background:#6b0c36; /* Solid colour fall-back */
background:#fff; /* It'll look nice semi-transparent */
font-color:#333;
text-decoration:none;
}
#nav li:hover ul a{ /* Override some top level styles when dropdown is hovered */
text-decoration:none;
-webkit-transition:-webkit-transform 0.075s linear;
}
#nav li:hover ul li a:hover{ /* Set styles for dropdown when items are hovered */
/* background:#333; Solid colour fall-back */
background:rgba(51,51,51,0.75); /* THIS IS HOVER BOX BG. It'll look nice semi-transparent */
text-decoration:none;
-moz-transform:scale(1.03);
-webkit-transform:scale(1.03);
}
You changed the top level list to position:absolute which meant that it gets passed down to the nested list elements and messes up the sub list. Just reset the nested list.
#nav ul li {
padding-top:1px; /* Introducing a padding between the li and the a give the illusion spaced items */
float:none;
[B] position:static;[/B]
}