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 7 of 7
  1. #1
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,179
    Thanks
    174
    Thanked 257 Times in 257 Posts

    centering in a Div

    I have a list menu that is placed in a div. For some reason when i type text-align:center it wont do anything, do i have to set a huge margin or padding left to it?

    heres my css code:
    Code:
    #navctrl {
    background-color: #336666;
    width:100%;
    height:25px;
    position:absolute;
    margin-top:75px;
    margin-left:0px;
    border-top:2px solid #FFFFFF;
    border-bottom:2px solid #FFFFFF;
    z-index:25;
    font-family:Verdana, Arial, Helvetica, sans-serif;
    color:#FFFFFF;
    font-size:12px;
    }
    
    
    #navctrl li {
    float:left;
    position:relative;
    list-style-type:none;
    border-right:1px solid #000000;
    text-align:center;
    vertical-align:
    }
    thanks

  • #2
    Regular Coder
    Join Date
    Feb 2007
    Location
    Canada
    Posts
    924
    Thanks
    10
    Thanked 56 Times in 55 Posts
    It is absolutely positioned.

    Might need to see some more code, or a link to the page would be best.

  • #3
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,179
    Thanks
    174
    Thanked 257 Times in 257 Posts
    well, is there anyway to get around the absolute position? There is only a div in the html section, not much code!

  • #4
    Regular Coder
    Join Date
    Feb 2007
    Location
    Canada
    Posts
    924
    Thanks
    10
    Thanked 56 Times in 55 Posts
    I rarely use position:absolute, myself, so yes, it can be avoided, but as for your page, I can't say, need to see some code, or ideally, a link to the page.

  • #5
    New Coder
    Join Date
    Oct 2007
    Location
    NC
    Posts
    39
    Thanks
    3
    Thanked 1 Time in 1 Post
    It's hard to say w/o the full coding of the page, but I'd say just drop the "position:absolute;" if it doesn't screw up the rest of the page.

  • #6
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,179
    Thanks
    174
    Thanked 257 Times in 257 Posts
    im sorry, i thought position absolute was the best thing to use to place images right?

  • #7
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    The only time you really need to have something absolutely positioned is if it must go over the top of something. I suggest using

    Code:
    div#outer
    {
      text-align:center;
    }
    
    div#inner
    {
     margin:0 auto;
    }
    P.S position:absolute has nothing to do with placing images. It is to do with how the box is positioned.
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

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