How do i center something in firefox using html?

Discussion in 'HTML & Website Design' started by globestar, Aug 15, 2008.

  1. #1
    I usually use the <center> tag which works in IE but it does not work for Firefox
     
    If someone posts a solution, use the "Best Answer" link in their post to pick it as the best answer.
    globestar, Aug 15, 2008 IP
  2. Gaelian

    Gaelian Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    y0,
    it depends

    these solution works in almost all web browser:

    1. you can use in css - margin: 0 auto; for any div without float
    2. if you have div with float but you gave toi that div fixed width you can use:
    div {position: relative; float:left; width: 400px; left: 50%; margin-left: -200px; /*margin left = half of div width*/ }

    and here is better source:
    http://www.simplebits.com/notebook/2004/09/08/centering.html
     
    Gaelian, Aug 15, 2008 Set Best Answer IP
  3. globestar

    globestar Guest

    Best Answers:
    0
    #3
    what if i want to center a google adsense ad
     
    globestar, Aug 15, 2008 Set Best Answer IP
  4. mysstiq

    mysstiq Peon

    Messages:
    22
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Enclose that in a div and center the div as Gaelin pointed out e.g.

    .adsense-rectangle {
    width: 400px;
    height:whatever;
    margin: 0 auto;
    }
    Code (markup):
    <div class="adsense-rectagle">
    your adsense code here !
    </div>
    HTML:
    note that this will center the div within its container.
     
    mysstiq, Aug 15, 2008 Set Best Answer IP
  5. Skullborg

    Skullborg Guest

    Messages:
    757
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    what about just <div align="center"> adsense code here </div> :p
     
    Skullborg, Aug 15, 2008 Set Best Answer IP
  6. globestar

    globestar Guest

    Best Answers:
    0
    #6
    globestar, Aug 15, 2008 Set Best Answer IP
  7. globestar

    globestar Guest

    Best Answers:
    0
    #7
    I figured it out. It was just something wrong with my drupal module
     
    globestar, Aug 15, 2008 Set Best Answer IP
  8. XenFen

    XenFen Banned

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    <div align="center">Info Here</div>
     
    XenFen, Aug 15, 2008 Set Best Answer IP
  9. bryanfilm

    bryanfilm Peon

    Messages:
    101
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    XenFen is right use <div align="center">Info Here</div> and it will work for you. Basically your placing your info in a div and then using the align="center". This will work great in firefox and IE
     
    bryanfilm, Aug 17, 2008 Set Best Answer IP
  10. jezzz

    jezzz Notable Member

    Messages:
    4,884
    Likes Received:
    190
    Best Answers:
    0
    Trophy Points:
    200
    #10
    Yeah! it will really works :) do it
     
    jezzz, Aug 17, 2008 Set Best Answer IP
  11. TheHumaNetwork

    TheHumaNetwork Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    <center>Something</center>