Go Back   CodingForums.com > :: Client side development > JavaScript programming

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 01-16-2013, 04:06 AM   PM User | #1
jake7363
New Coder

 
Join Date: Nov 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
jake7363 is an unknown quantity at this point
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
jake7363 is offline   Reply With Quote
Old 01-16-2013, 02:35 PM   PM User | #2
hdewantara
Regular Coder

 
hdewantara's Avatar
 
Join Date: Aug 2009
Location: Jakarta, Indonesia.
Posts: 287
Thanks: 4
Thanked 39 Times in 39 Posts
hdewantara is an unknown quantity at this point
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?
hdewantara is offline   Reply With Quote
Old 01-16-2013, 02:52 PM   PM User | #3
DanInMa
Senior Coder

 
DanInMa's Avatar
 
Join Date: Nov 2010
Location: Salem,Ma
Posts: 1,307
Thanks: 12
Thanked 204 Times in 204 Posts
DanInMa is on a distinguished road
margin 0 auto will work if the element has a set width, not a percentage.
__________________
- Firebug is a web developers best friend! - Learn it, Love it, use it!
- Validate your code! - JQ/JS troubleshooting
- Using jQuery with Other Libraries - Jslint for Jquery/other JS library users
DanInMa 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 08:48 PM.


Advertisement
Log in to turn off these ads.