Help me center this Adsense block

Discussion in 'HTML & Website Design' started by touchAshley, Jun 8, 2008.

  1. #1
    I'm trying to center adsense in my forum but it only wants to center in IE. not firefox.

    I'm using <div align="center">

    I don't know what else to use to make it work for firefox too.

    Thanks :)
     
    touchAshley, Jun 8, 2008 IP
  2. ckgni

    ckgni Active Member

    Messages:
    208
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Better use this:

    
    <div style="text-align:center">
    code here
    </div>
    
    Code (markup):
    usually it works on all browsers
     
    ckgni, Jun 8, 2008 IP
  3. touchAshley

    touchAshley Active Member

    Messages:
    1,762
    Likes Received:
    85
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Just tried it but it still didn't work. Thanks for the quick response :)

    I wonder if it matters that it's a .php file
     
    touchAshley, Jun 8, 2008 IP
  4. ckgni

    ckgni Active Member

    Messages:
    208
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Sounds strange, because even if it was a CSS issue, the above code should work. No PHP does not matter. The final HTML code is always processed by the browser, not the server.

    I am going to give you another code snipet that usually works. It is not actually centering, it puts some margin on the left of the text:

    
    <div style="margin-left:140px;">
    text
    </div>
    
    Code (markup):
    See if it works. You may need to change 140 to another number to better position the code.
    It is always working for me. If it does not make any difference on your page it appears that you should change your CSS file. :)
     
    ckgni, Jun 8, 2008 IP
  5. sachin410

    sachin410 Illustrious Member

    Messages:
    6,422
    Likes Received:
    573
    Best Answers:
    0
    Trophy Points:
    410
    #5
    Can you share the url?
     
    sachin410, Jun 8, 2008 IP
  6. nicangeli

    nicangeli Peon

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #6
    
    <div class="center">
    <!-- ADSENSE -->
    </div>
    
    Code (markup):
    
    .center
    {
    margin: 0 auto;
    text-align: center;
    }
    
    Code (markup):
     
    nicangeli, Jun 8, 2008 IP
  7. touchAshley

    touchAshley Active Member

    Messages:
    1,762
    Likes Received:
    85
    Best Answers:
    0
    Trophy Points:
    90
    #7
    touchAshley, Jun 8, 2008 IP
  8. sachin410

    sachin410 Illustrious Member

    Messages:
    6,422
    Likes Received:
    573
    Best Answers:
    0
    Trophy Points:
    410
    #8
    Try this:

    <table width="100%" align="center">
    <td bgcolor="#EAFCB5" align="center" >
    
    Adsense
    
    </td>
    </table>
    
    Code (markup):
    Change the colour as per your forum.
     
    sachin410, Jun 8, 2008 IP
    touchAshley likes this.
  9. nicangeli

    nicangeli Peon

    Messages:
    828
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #9
    <div style="margin: 0 auto; text-align: center;">

    Are you sure that doesn't work?
     
    nicangeli, Jun 8, 2008 IP
  10. touchAshley

    touchAshley Active Member

    Messages:
    1,762
    Likes Received:
    85
    Best Answers:
    0
    Trophy Points:
    90
    #10
    Wow that worked perfectly. Not only did it center it but.. The adsense block was meant to be right under the first post. But It was showing before the first post. So I said I could deal with that. Your code made it show after the first post (like i originally wanted) Now I just gotta fix the color.

    Thanks :)
     
    touchAshley, Jun 8, 2008 IP