Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    1
    Member #
    37846

    html and css navigation bar help

    Any help with this .. I need to make my top navigation bar stretch across the website as well as be fixed when scrolling down the page, like on "http://www.marbletree.co.uk/" or "http://thesoundibiza.com/" or "http://www.commercekitchen.com/"....

    my html code looks like:

    <div id="menu_bar">
    <div class="table">
    <ul id="menuitems">
    <li><a href="Index.html">something</a></li>
    <li><a href="something.html">something</a></li>
    <li><a href="something.html">something</a></li>
    <li><a href="something.html">something</a></li>
    <li>
    <form id="search_box" action="search" method="get">
    <input type="text" name"search" />
    <button id="search_icon" type="submit"><img src="searchicon.png" width="21" height="19"/>
    </button>
    </form>
    </li>
    <li><a href="something.html">something</a></li>
    <li><a href="something.html">something</a></li>
    </ul>
    </div>
    </div>

    and css code looks like:


    #menu_bar {
    height: 100%;
    background-color:#FC6;

    }

    .table {

    display: table;
    position: fixed;


    }

    ul#menuitems {
    max-width: 100%;
    padding-top: 1px;

    }

    ul#menuitems li {
    display: inline;


    }

    #search_box {
    display:inline
    }

    #search_icon {
    display:inline

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Give #menu_bar a defined height that isn't a percentage, a width of 100%, and make it position:fixed. Remove position:fixed from .table

    Also, your HTML is a mess. You have several syntax errors, and you're using way more elements than you need to. You may find it easier to do things if you minimize the extra junk. You can accomplish all of it with just a nav and a ul (truth be told, you don't need the nav element, but it's more semantic that way, but if you aren't using HTML5, you can't use it). You also don't need any of the selectors you've used.

    HTML Code:
    <nav>
      <ul>
        <li><a href="index.html">something</a></li>
        <li><a href="something.html">something</a></li>
        <li><a href="something.html">something</a></li>
        <li><a href="something.html">something</a></li>
        <li> 
          <form action="search" method="get"> 
            <input type="text" name="search" />
            <button type="submit">
              <img src="searchicon.png" width="21" height="19" />
            </button>
          </form>
        </li>
        <li><a href="something.html">something</a></li>
        <li><a href="something.html">something</a></li>
      </ul>
    </nav>
    That's all you really need.
    Last edited by Ronald Roe; Nov 30th, 2013 at 07:21 AM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:46 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com