How can i center a div within a table?

Discussion in 'CSS' started by grobar, Apr 10, 2007.

  1. #1
    Ihave a <td>:
    
    <td class="message-poster-box" align="center">	
         Forum Admin
         <br /><br />
         <div style="display: block; align: center; border:1px solid; background-image: url('http://dev.billiardsforum.info/forum/avatars/personal/778-160Raptox.jpg');background-repeat: no-repeat; background-position: center; height:80px; width:80px;">
    	</div>
    210 Posts
    
    </td>
    Code (markup):
    How can i get that div to center in there? (it leans left in FF)

    Here is the class="message-poster-box"...

    .message-poster-box
    {
    padding: 0 20px 20px 5px;
    margin: 0;
    width: 173px;
    text-align: center;
    border-bottom: 1px solid #d0d0d0;
    border-left: 1px solid #d0d0d0;
    border-right: 1px solid #d0d0d0;
    }
    Code (markup):

     
    grobar, Apr 10, 2007 IP
  2. deques

    deques Peon

    Messages:
    206
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    have you tried to remove align="center" from the td and the align: center in your inline style?

    from what i can see it should work, since you have text-align: center in your selector

    edit: maybe try to have text-align: center in the div instead
     
    deques, Apr 10, 2007 IP
  3. Bagi Zoltán

    Bagi Zoltán Well-Known Member

    Messages:
    364
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #3
    I guess the margin:auto css attributum will solve your problem.
     
    Bagi Zoltán, Apr 10, 2007 IP
    grobar likes this.
  4. MTbiker

    MTbiker Well-Known Member

    Messages:
    2,536
    Likes Received:
    123
    Best Answers:
    0
    Trophy Points:
    170
    #4
    Yeah try margin: auto or margin: 0 auto on the div.
     
    MTbiker, Apr 11, 2007 IP
    grobar likes this.
  5. grobar

    grobar Well-Known Member

    Messages:
    642
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    140
    #5
    Margin:auto did the trick,thanks!
     
    grobar, Apr 11, 2007 IP