SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Float question

  1. #1
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Float question

    I am kinda new working with CSS. I am trying to center a menu on a website, but I guess "center" is just not the right way to do it. So, how do I get my menu bar into the middle?

    Code:
    <table border="0" cellpadding="0" cellspacing="0" width="100%" id="wrapper" align="center"> 
    <tr>
      <td colspan="2">
        <div id="header" ><center>
          <img src="$script[imgfolder]logo3a.gif" alt="" />
        </div></center>
        <div id="navbar">
          <div style="float:right;font-weight:bold;"><a href="index.php">Home</a> | <a href="index.php?advsearch">Advanced Search</a> | <a href="index.php?topart">Most Popular</a> | <a href="index.php?toprated">Top Rated</a> | <a href="index.php?rss">RSS Syndicate</a> | <a href="index.php?do=sitemap">Sitemap</a> | <a href="http://www.webhostingreport.net">Forum</a></div>
        </div>
      </td>
    </tr>
    Right now it is set to the right.

    Thanks for any hint.

    Christoph
    The-USA dot net - PR4 Web Directory

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,424
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    try:

    margin: auto;

    That's the CSS way to center a block elevel element.

  3. #3
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm, that did not work (at least in my situation). I had removed the float:right; from aboves code example and replaced it with the "margin: auto;". Any idea? Is that the wrong place to center the menu bar?

    Christoph
    The-USA dot net - PR4 Web Directory

  4. #4
    SitePoint Guru
    Join Date
    Mar 2001
    Location
    Highlands Ranch, Colorado
    Posts
    614
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, found it.

    text-align: center

    At least it worked in my situation.

    Christoph
    The-USA dot net - PR4 Web Directory


Bookmarks

Posting Permissions

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