Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    centering navigation bar


    centering navigation bar


    hello,
    I have a javascript navigation bar I am trying to center in a <div>. Because I don't want to fix a width to the div, I am using percentages which -from what I read- makes it impossible to use CSS to center the bar. I have tried all the methods mentioned in CSS forums to find out for myself.
    It has been a while (a few years) since I did any web developing, my Dreamweaver is out of date (and I am out of touch) with HTML 5 and CSS3. Prior to that, the software I used to create the menu had a plug-in for DW and it centered it automatically. Now, I need to do it manually and can only believe that it is a function of javascript.
    To keep it simple, here is my example:

    HTML-
    <div class="navbar">
    <script type="text/javascript" src="navbars/navTop/biztech.js"></script>
    </div>

    CSS-
    .navbar{
    display:block;
    margin:0 auto;
    width:100%;
    }

    I tried using "ul {display:inline-block;}", but that didn't work, either.

    Any help is appreciated.

    Jake

  • #2
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    346
    Thanks
    9
    Thanked 51 Times in 50 Posts
    I still believe it is within CSS scope, since centering is a page-layout thing. May we see an URL/ link to the page where your navigation-bar resides?

  • #3
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    margin 0 auto will work if the element has a set width, not a percentage.


  •  

    Posting Permissions

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