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 02-17-2012, 09:22 PM   PM User | #1
MasterRenny
New Coder

 
Join Date: Oct 2011
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
MasterRenny is an unknown quantity at this point
Menu Styling Problem

Ok this is basically my first ever menu navigation and im having a few problems with it, that is problem when it drops down

http://test.masterrenny.com/ <<< thats it in action

Code:
nav { font-family:'BebasNeueRegular'; display:block; border:1px solid #222; position:relative; margin-top: 0; margin-right: auto; margin-bottom: 20px; margin-left: auto; text-transform:uppercase; font-size:18px }
nav ul { padding:0; margin:0; }
nav li { position:relative; float:left; list-style-type:none; height:50px; }
nav li:hover { background:#111; color: white; text-shadow: 0 1px black; }
nav ul:after { content:"."; display:block; height:0; clear:both; visibility:hidden; }
nav li a { color: #999; display: block; line-height: 11px; height: 10px; padding: 20px; border-right: 1px solid #333; box-shadow: -1px 0 #000 inset; -moz-box-shadow: -1px 0 #000 inset; -webkit-box-shadow: -1px 0 #000 inset; text-shadow: 0 -1px black; }
nav li a:focus { outline:none; text-decoration:underline; }
nav li:first-child a { border-left:none; }
nav li.last a { border-right:none; }
nav a span { display:block; float:right; margin-left:5px; }
nav ul ul { display:none; min-width:168px; padding:20px; position:absolute; left:0; background:#565656; }
nav ul ul li { float:none; }
nav ul ul a { padding:5px 10px; border-left:none; border-right:none; font-size:14px; }
nav ul ul a:hover { background-color:#555; }

The CSS code im using

Code:
<nav>
    <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Test</a>
<ul>
              <li><a href="#">Test link</a>
<ul>
                  <li><a href="#">Example</a></li>
                  <li><a href="#">Hehe</a></li>
                </ul>
              </li>
              <li><a href="#">Link</a></li>
            </ul>
          </li>
          <li><a href="#">Last link ok </a></li>
    </ul>
</nav>
		                <script>
$(document).ready(function () { 
     
    $('nav li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);
 
        }, 
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);         
        }
    );
     
});
</script>


the link "test" is the drop down part, its surpose to have a arch of two but as u can see, its messed up and its really frustrating me
MasterRenny is offline   Reply With Quote
Old 02-18-2012, 09:57 AM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
This is a jQuery problem really. Your problem is here:

Code:
		                <script>
$(document).ready(function () { 
     
    $('nav li').hover(
        function () {
            //show its submenu
            $('ul', this).slideDown(100);
 
        }, 
        function () {
            //hide its submenu
            $('ul', this).slideUp(100);         
        }
    );
     
});
</script>
So, what this is saying is "on hover of an li within nav, show any ul within that li". Result - both the second and third level uls within your menu are shown.

Your script should be (for example, there's a few ways of doing this):

Code:
$(this).children('ul').slideDown(100);
The .children selector restricts the selection to the immediate children only, which is what you want.

Worth mentioning that this is possible with css only, as currently your menu wouldn't work at all for a user with js disabled.

Your page also appears to be rendering the php code directly if you view the source, so there's something else not right on your server/page.
SB65 is offline   Reply With Quote
Old 02-18-2012, 12:16 PM   PM User | #3
MasterRenny
New Coder

 
Join Date: Oct 2011
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
MasterRenny is an unknown quantity at this point
Well that was just a testing ground just so i could have some idea what its like, but even on my wordpress theme which its intended for (www.masterrenny.com) the drop down still doesnt work correctly

Last edited by MasterRenny; 02-18-2012 at 12:19 PM..
MasterRenny is offline   Reply With Quote
Old 02-18-2012, 12:41 PM   PM User | #4
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,827
Thanks: 9
Thanked 685 Times in 679 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
Not surprising, since that page uses css not jQuery for the dropdown.

Are you trying to implement the jQuery on your Wordpress page - I can't see it anywhere?

And, actually, the dropdown appears OK on that page, in that only one level is displayed on the initial hover.

What, exactly, is the problem you're trying to fix?

Last edited by SB65; 02-18-2012 at 12:46 PM..
SB65 is offline   Reply With Quote
Users who have thanked SB65 for this post:
MasterRenny (02-19-2012)
Old 02-18-2012, 09:38 PM   PM User | #5
MasterRenny
New Coder

 
Join Date: Oct 2011
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
MasterRenny is an unknown quantity at this point
Quote:
Originally Posted by SB65 View Post
Not surprising, since that page uses css not jQuery for the dropdown.

Are you trying to implement the jQuery on your Wordpress page - I can't see it anywhere?

And, actually, the dropdown appears OK on that page, in that only one level is displayed on the initial hover.

What, exactly, is the problem you're trying to fix?
On the Guildwars drop down menu when you get to the uncategorized the links that appear should be at the right but i cant seem to get it to do it :/ Ive aded the jquery animation for it to slide down but it doesnt work for some reason so i removed it
MasterRenny is offline   Reply With Quote
Old 02-19-2012, 01:31 AM   PM User | #6
MasterRenny
New Coder

 
Join Date: Oct 2011
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
MasterRenny is an unknown quantity at this point
Edit: Dont Matter, Problem solved thanks for your help.
MasterRenny 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 01:48 AM.


Advertisement
Log in to turn off these ads.