Image Centering Problem

Discussion in 'ASP .Net Web Controls' started by Murdoc, Sep 13, 2004.

  1. Murdoc

    Murdoc Guest

    Hi all,

    I am currently using the server-side Image control to display images, with the image paths being
    stored in an SQL database. Everything is working fine, but I have run into a small problem with the
    image sizes. Currently, some images are smaller than others, and when they are displayed in the
    control, they are stretched, and hence distorted.

    Is there any way I can automatically centre the image without changing the size of the control? The
    only other options I would have then, would be either modifying the size of the control for each
    image, or resizing all the images.

    --
    Murdoc
    ; =================================
    "Insanity in individuals is something rare - but in groups, parties, nations and epochs, it is the
    rule."
    -- Friedrich Nietzsche

    "All Congresses and Parliaments have a kindly feeling for idiots, and a compassion for them, on
    account of personal experience and heredity."
    -- Mark Twain

    "A single death is a tragedy, a million deaths is a statistic."
    -- Joseph Stalin
    Murdoc, Sep 13, 2004
    #1
    1. Advertising

  2. How about putting a single-cell table with a fixed sized and no borders
    around the image control. Centre the contents of the cell with the align
    attribute.

    Then, don't set any image size for the image control so that it sizes itself
    according to the image it gets. That way, the all of the images would take
    up the same space but the smaller ones would appear in the centre.

    Would that work?

    Ken

    "Murdoc" <> wrote in message
    news:...
    > Hi all,
    >
    > I am currently using the server-side Image control to display images, with
    > the image paths being
    > stored in an SQL database. Everything is working fine, but I have run into
    > a small problem with the
    > image sizes. Currently, some images are smaller than others, and when they
    > are displayed in the
    > control, they are stretched, and hence distorted.
    >
    > Is there any way I can automatically centre the image without changing the
    > size of the control? The
    > only other options I would have then, would be either modifying the size
    > of the control for each
    > image, or resizing all the images.
    >
    > --
    > Murdoc
    > ; =================================
    > "Insanity in individuals is something rare - but in groups, parties,
    > nations and epochs, it is the
    > rule."
    > -- Friedrich Nietzsche
    >
    > "All Congresses and Parliaments have a kindly feeling for idiots, and a
    > compassion for them, on
    > account of personal experience and heredity."
    > -- Mark Twain
    >
    > "A single death is a tragedy, a million deaths is a statistic."
    > -- Joseph Stalin
    Ken Cox [Microsoft MVP], Sep 14, 2004
    #2
    1. Advertising

  3. Murdoc

    Murdoc Guest

    Ken Cox [Microsoft MVP] wrote:

    > How about putting a single-cell table with a fixed sized and no borders around the image control.
    > Centre the contents of the cell with the align attribute.
    >
    > Then, don't set any image size for the image control so that it sizes itself according to the
    > image it gets. That way, the all of the images would take up the same space but the smaller ones
    > would appear in the centre.
    >
    > Would that work?


    Yeah, it will. Thanks. I didn't think it would be that simple.

    --
    Murdoc
    ; =================================
    "Insanity in individuals is something rare - but in groups, parties, nations and epochs, it is the
    rule."
    -- Friedrich Nietzsche

    "All Congresses and Parliaments have a kindly feeling for idiots, and a compassion for them, on
    account of personal experience and heredity."
    -- Mark Twain

    "A single death is a tragedy, a million deaths is a statistic."
    -- Joseph Stalin
    Murdoc, Sep 14, 2004
    #3
    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. Jerry Camel

    Centering an image with text

    Jerry Camel, Sep 23, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    523
    John Timney \(ASP.NET MVP\)
    Sep 23, 2005
  2. Richard

    Re: Centering image on page?

    Richard, Jun 25, 2003, in forum: HTML
    Replies:
    0
    Views:
    3,737
    Richard
    Jun 25, 2003
  3. Jerry Muelver

    Re: Centering image on page?

    Jerry Muelver, Jun 25, 2003, in forum: HTML
    Replies:
    0
    Views:
    828
    Jerry Muelver
    Jun 25, 2003
  4. mr_vocab
    Replies:
    4
    Views:
    680
    mr_vocab
    May 24, 2004
  5. Jeff
    Replies:
    1
    Views:
    554
    Alexey Smirnov
    May 15, 2007
Loading...

Share This Page