Centered Image

Discussion in 'HTML' started by Bazil, Dec 12, 2004.

  1. Bazil

    Bazil Guest

    Hi all,

    am just learning css so please bear with me.

    I discovered the following to center an image without a table

    img#logo {position: absolute;
    left: 50%;
    width: 630px; height: 40px;
    margin-left: -315px}

    Of course the next elements now appear below the image.

    Q. Once position: absolute is used, does that force the use of absolute
    for all following elements? Is there another way?

    TIA,

    Bryan
     
    Bazil, Dec 12, 2004
    #1
    1. Advertising

  2. Bazil

    Bazil Guest

    Bazil wrote:
    > Hi all,
    >
    > am just learning css so please bear with me.
    >
    > I discovered the following to center an image without a table
    >
    > img#logo {position: absolute;
    > left: 50%;
    > width: 630px; height: 40px;
    > margin-left: -315px}
    >
    > Of course the next elements now appear below the image.
    >
    > Q. Once position: absolute is used, does that force the use of absolute
    > for all following elements? Is there another way?


    Another way, put it in a div :-

    div#logo {width: 630px; margin: 0px auto}

    Acceptable?

    The previous Q still stands...

    Bryan
     
    Bazil, Dec 12, 2004
    #2
    1. Advertising

  3. Bazil wrote:
    > div#logo {width: 630px; margin: 0px auto}


    Even better, do this:
    img#logo {display: block; margin: auto;}
     
    Leif K-Brooks, Dec 12, 2004
    #3
  4. Bazil

    Mr Bean Guest

    Leif K-Brooks wrote:
    > Bazil wrote:
    >
    >> div#logo {width: 630px; margin: 0px auto}

    >
    >
    > Even better, do this:
    > img#logo {display: block; margin: auto;}



    This would work with a container as well?
     
    Mr Bean, Dec 13, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Wade

    Controls Always Centered

    Ryan Wade, Oct 4, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    366
    Steve C. Orr [MVP, MCSD]
    Oct 4, 2004
  2. Nico
    Replies:
    0
    Views:
    462
  3. palmis
    Replies:
    4
    Views:
    796
    palmis
    Jan 23, 2006
  4. simast
    Replies:
    2
    Views:
    385
  5. Roger
    Replies:
    1
    Views:
    379
    Roger
    Dec 10, 2006
Loading...

Share This Page