www.webdeveloper.com
Results 1 to 8 of 8

Thread: page links to drop down menu

  1. #1
    Join Date
    Mar 2013
    Posts
    7

    page links to drop down menu

    I just created a horizontal drop down navigation bar in dreamweaver using CSS that I
    followed from a tutorial.

    The problem is: I have my navigation bar on all the pages - and I also created all my
    pages that correspond to the drop down links.

    They way I have linked pages in the past (with just a regular nav bar) is to highlight the text in the document and then in the Properties Panels dragged the 'little circle' icon to the page I want it to go to in the Files Panel.

    With this drop down menu - it is only in the code - so how do I link - lets say the HOME page to the page in the drop down menu ?

    Thank you.

  2. #2
    Join Date
    Mar 2013
    Posts
    7
    this is my code - and it isn't working. what am i doing wrong ?
    thank you.

  3. #3
    Join Date
    Mar 2013
    Posts
    7
    oops. here it is:

    <div id="navigation">
    <ul id="navmenu">
    <li><a href="index.php">HOME</a></li>
    <li><a href="aboutus.php">ABOUT</a></li>
    <li><a href="collections.php">COLLECTIONS</a>
    <ul class="sub1">
    <li><a href="mountain.php">MOUNTAIN</a></li>
    <li><a href="ocean.php">OCEAN</a></li>
    <li><a href="bohemian.php">BOHEMIAN</a></li>
    <li><a href="native.php">NATIVE</a></li>
    <li><a href="green.php">GREEN</a></li>
    <li><a href="moon.php">MOON</a></li>
    <li><a href="plants.php">PLANTS</a></li>
    </ul>
    </li>
    <li><a href="offerings.php">OFFERINGS</a>
    <ul class="sub1">
    <li><a href="seasons.php">SEASONS</a></li>
    <li><a href="installs.php">INSTALLS</a></li>
    <li><a href="storefront.php">STOREFRONT</a></li>
    <li><a href="lingerie.php">LINGERIE</a></li>
    </ul>
    </li>
    <li><a href="contact.php">CONTACT</a></li>
    <li><a href="order.php">ORDER</a></li>
    </ul>
    </div>

  4. #4
    Join Date
    May 2005
    Location
    Gold Coast (MS)
    Posts
    2,208
    Make sure paths are correct if menu on a page is outside a common directory.

    Absolute and Relative Paths: http://webdesign.about.com/od/beginn.../aa040502a.htm

  5. #5
    if are you facing any problem with dropdown menu, you can be find on google, there you will be get good code, i hope you will get best.

  6. #6
    Join Date
    Feb 2013
    Posts
    81
    Just think of a drop-down menu like a staircase going down.

    #nav
    #nav ul
    #nav ul li
    #nav ul li a
    #nav ul li a: hover

    drop-down
    #nav li ul
    #nav li ul li
    etc....

    I changed navigation to nav for I'm lazy added a little javascript (although I don't think it's necessary?) and I also used inline css styling. I would recommend using an external file for your css & javascript?


    Here's an example of your menu
    HTML Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Drop-Down Example</title>
    <style type="text/css">
    /* MAIN NAVIGATION 
    --------------------------------------*/
    #nav{ 
    	float: left;
    	width: 1000px;
    	height: 25px;
    	padding: 0px;
    	margin: 0px;
    }
    
    #nav ul {
    	list-style: none;
    	padding: 0px;
    	margin: 0px;
    }
    
    #nav ul li {
    	float: left;
    	width: auto;
    	padding: 0px;
    	margin: 0px;
    }
    
    #nav a {
    	display: block;
    	width: auto;
    	height: 25px;
    	background-color: #fbfbfb;
    	font-family: arial, helvetica, sans-serif;
    		font-size: 1.2em;
    		line-height: 25px;
    		font-weight: bold;
    		color: #bbb;
    	text-decoration: none;
    	padding: 0 75px 0 0;
    	margin: 0px;
    }
    
    #nav ul li a:hover {
    	color: #000;
    }
    
    
    /* DROPDOWN MENU - MAIN NAVIGATION
    -------------------------------------- */
    #nav li ul { 
    	width: 200px;
    	position: absolute;
    		left: -999em; /* using left instead of display to hide menus because display: none isn't read by screen readers */
    	background-color: #fff;
    }
    
    #nav li ul li a {
    	width: 200px;
    	height: 20px;
    	font-weight: normal;
    	background-color: #fff;
    	border-bottom: 1px solid #ccc;
    	padding: 0px;
    	margin: 0px;	
    }
    
    #nav li:hover ul, #nav li.sfhover ul { /* javascript IE fix */
    	left: auto;
    	width: 200px;
    }
    
    
    </style>
    <script type="text/javascript">
    	sfHover = function() {
    		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    		for (var i=0; i<sfEls.length; i++) {
    			sfEls[i].onmouseover=function() {
    				this.className+=" sfhover";
    			}
    			sfEls[i].onmouseout=function() {
    				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    			}
    		}
    	}
    	if (window.attachEvent) window.attachEvent("onload", sfHover);
    </script>
    </head>
    
    <body>
    <div id="nav">
      <ul>
        <li><a href="index.php">HOME</a></li>
        <li><a href="aboutus.php">ABOUT</a></li>
        <li><a href="collections.php">COLLECTIONS</a>
          <ul>
            <li><a href="mountain.php">MOUNTAIN</a></li>
            <li><a href="ocean.php">OCEAN</a></li>
            <li><a href="bohemian.php">BOHEMIAN</a></li>
            <li><a href="native.php">NATIVE</a></li>
            <li><a href="green.php">GREEN</a></li>
            <li><a href="moon.php">MOON</a></li>
            <li><a href="plants.php">PLANTS</a></li>
          </ul>
        </li>
        <li><a href="offerings.php">OFFERINGS</a>
          <ul>
            <li><a href="seasons.php">SEASONS</a></li>
            <li><a href="installs.php">INSTALLS</a></li>
            <li><a href="storefront.php">STOREFRONT</a></li>
            <li><a href="lingerie.php">LINGERIE</a></li>
          </ul>
        </li>
        <li><a href="contact.php">CONTACT</a></li>
        <li><a href="order.php">ORDER</a></li>
      </ul>
    </div>
    </body>
    </html>

  7. #7
    Join Date
    Feb 2013
    Posts
    81
    I notice you are using php, you can even do this dynamically (although this is old code, I would convert it to mysqli or PDO):

    PHP Code:
        function navigation($sel_subject$sel_page$public false) {
            
    $output "<ul class=\"subjects\">";
            
    $subject_set get_all_subjects($public);
            while (
    $subject mysql_fetch_array($subject_set)) {
                
    $output .= "<li";
                if (
    $subject["id"] == $sel_subject['id']) { $output .= " class=\"selected\""; }
                
    $output .= "><a href=\"edit_subject.php?subj=" urlencode($subject["id"]) . 
                    
    "\">{$subject["menu_name"]}</a></li>";
                
    $page_set get_pages_for_subject($subject["id"], $public);
                
    $output .= "<ul class=\"pages\">";
                while (
    $page mysql_fetch_array($page_set)) {
                    
    $output .= "<li";
                    if (
    $page["id"] == $sel_page['id']) { $output .= " class=\"selected\""; }
                    
    $output .= "><a href=\"content.php?page=" urlencode($page["id"]) .
                        
    "\">{$page["menu_name"]}</a></li>";
                }
                
    $output .= "</ul>";
            }
            
    $output .= "</ul>";
            return 
    $output;
        } 

  8. #8
    Join Date
    Apr 2013
    Posts
    1
    <form>
    <label><u>S</u>earch Engines</label>
    <select accesskey="S" onchange="goToPage(this.options(this.selectedIndex).value)">
    <option selected>Please select one</option>
    <option value="http://search.msn.com/">MSN Search</option>
    <option value="http://www.google.com/">Google</option>
    <option value="http://www.search.com/">Search.com</option>
    <option value="http://www.dogpile.com/">Dogpile</option>
    </select>
    form>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles