Quick CSS Problem - Trying To Get List To Line Up Centrally

Discussion in 'CSS' started by bad_bob00, Sep 1, 2010.

  1. #1
    Hi there,

    Was wondering if someone could please help. I'm trying to get a list to line up centrally on my page, at the moment it is stuck to the left. You can see the problem at this page (the very top line of text I want to align centrally).
    http://www.the-biomatrix.net

    Here is the code on the index.htm page:


    And this is the code in the style.css file:


    If anyone can help then that would be great, I'm sure it can't be a massive problem, I'm probably just making a silly mistake.

    Cheers :)
     
    bad_bob00, Sep 1, 2010 IP
  2. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #2
    1. set left-right margin of #dogmenu to auto
    2. assign a width to #dogmenu

    If I take your css, then,
     
    radiant_luv, Sep 1, 2010 IP
    bad_bob00 likes this.
  3. bad_bob00

    bad_bob00 Active Member

    Messages:
    3,472
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Thank you very much Radiant_luv. I've set the width as 80% and it appears okay in my browser. Would appreciate it if anyone could check out the URL and see if the top line appears to be central.

    Thanks again!
     
    bad_bob00, Sep 1, 2010 IP
  4. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Anytime. :)
    checked in FF, your last menu item is pushed to next line; that's because there is not enough room for all items when you've specified 80%, why not set a width 985px, that's shows okay, checked in firebug.
     
    radiant_luv, Sep 1, 2010 IP
  5. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Nope, it really is a problem if you want to avoid setting a width :D

    One way is to use text-align: center for the list. Another way is to use display: table but that did not work in IE7.
    The floated list items did not work in IE7 either so I had to use display: inline, but that meant removing the anchor blocks. :rolleyes:

    
    * {
    	margin: 0;
    	padding: 0;
    }
    
    #dogmenucontainer{
    	background: #000044;
    	border:1px solid #000;
    	font: 14px "Century gothic",verdana, Arial, sans-serif;
    	height:21px;
    }
    
    #dogmenu ul {
    	list-style: none;
    	text-align: center;
    }
    
    #dogmenu a {
    	color: #fff;
    	padding: 1px 10px;
    }
    
    #dogmenu a:hover {
    	color: #A7A7A7;
    	text-decoration: none;
    }
    
    #dogmenu li {
    	display: inline;
    } 
    
    Code (markup):
     
    Last edited: Sep 1, 2010
    Cash Nebula, Sep 1, 2010 IP
  6. bad_bob00

    bad_bob00 Active Member

    Messages:
    3,472
    Likes Received:
    56
    Best Answers:
    0
    Trophy Points:
    90
    #6
    Thanks guys, I've changed it again, hopefully its looking okay now.
     
    bad_bob00, Sep 1, 2010 IP
  7. CSM

    CSM Active Member

    Messages:
    1,047
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    55
    #7
    Sorry but I have to correct this:

    margin:0 auto; would not mean margin: right left ... totally wrong.

    It works like a clock: margin: TOP RIGHT BOTTOM LEFT.

    So if you use margin:0 auto you would set margin: TOP (0) RIGHT (auto) BOTTOM (0) LEFT (auto).
     
    CSM, Sep 1, 2010 IP
  8. radiant_luv

    radiant_luv Peon

    Messages:
    1,327
    Likes Received:
    34
    Best Answers:
    1
    Trophy Points:
    0
    #8
    lol. I din't know that :rolleyes:

    or let me help you out, I havn't kept this part "set left-right margin of #dogmenu to auto " inside "quote", did I? I think I'm clear that left & right margin to be set to auto. and the code inside the quote to help him out.

    sorry, this is offtopic; okay, can someone tell me more post means more rep? ...
     
    radiant_luv, Sep 1, 2010 IP