How to Shrink image size when browser size is reduced

Discussion in 'Javascript' started by Bob Richardson, Mar 7, 2005.

  1. Is it possible for an image to SHRINK (both height and width, keeping same
    h/w ratio) when the browser's width is reduced? It's easy to have both h & w
    increase, as needed, to fill up 100% of the <td>, but I don't see how to
    have the image shrink.

    Without JavaScript, the standard seems to be scrollbars when the browser
    shrinks. I'd like the picture to shrink in size and avoid the scrollbars.
    Bob Richardson, Mar 7, 2005
    #1
    1. Advertising

  2. Bob Richardson

    Randy Webb Guest

    Bob Richardson wrote:

    > Is it possible for an image to SHRINK (both height and width, keeping same
    > h/w ratio) when the browser's width is reduced? It's easy to have both h & w
    > increase, as needed, to fill up 100% of the <td>, but I don't see how to
    > have the image shrink.


    Percentages my friend, percentages.

    > Without JavaScript, the standard seems to be scrollbars when the browser
    > shrinks.


    Only for those that know no better, and that may indeed include me.

    > I'd like the picture to shrink in size and avoid the scrollbars.


    And what exactly does this have to do with Javascript?

    <img src="someImage.gif" width="100%">

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Randy Webb, Mar 7, 2005
    #2
    1. Advertising

  3. "Randy Webb" <> wrote in message
    news:...
    > Bob Richardson wrote:
    >
    >> Is it possible for an image to SHRINK (both height and width, keeping
    >> same
    >> h/w ratio) when the browser's width is reduced? It's easy to have both h
    >> & w
    >> increase, as needed, to fill up 100% of the <td>, but I don't see how to
    >> have the image shrink.

    >
    > Percentages my friend, percentages.
    >
    >> Without JavaScript, the standard seems to be scrollbars when the browser
    >> shrinks.

    >
    > Only for those that know no better, and that may indeed include me.
    >
    >> I'd like the picture to shrink in size and avoid the scrollbars.

    >
    > And what exactly does this have to do with Javascript?
    >
    > <img src="someImage.gif" width="100%">


    The above is exactly how I've coded the HTML. I think the IMG is 700 pixels
    wide. When you expand the size of your browser beyond 700, the picture's
    width and height both expand. But when the browser's width is less than 700,
    the picture does not shrink. Just scroll bars.

    Thus, I thought that perhaps a JavaScript function might work to reduce the
    size of the image.
    Bob Richardson, Mar 8, 2005
    #3
  4. "Bob Richardson" <bobr at whidbey dot com> wrote in message
    news:...
    >
    > "Randy Webb" <> wrote in message
    > news:...
    >> Bob Richardson wrote:
    >>
    >>> Is it possible for an image to SHRINK (both height and width, keeping
    >>> same
    >>> h/w ratio) when the browser's width is reduced? It's easy to have both h
    >>> & w
    >>> increase, as needed, to fill up 100% of the <td>, but I don't see how to
    >>> have the image shrink.

    >>
    >> Percentages my friend, percentages.
    >>
    >>> Without JavaScript, the standard seems to be scrollbars when the browser
    >>> shrinks.

    >>
    >> Only for those that know no better, and that may indeed include me.
    >>
    >>> I'd like the picture to shrink in size and avoid the scrollbars.

    >>
    >> And what exactly does this have to do with Javascript?
    >>
    >> <img src="someImage.gif" width="100%">

    >
    > The above is exactly how I've coded the HTML. I think the IMG is 700
    > pixels wide. When you expand the size of your browser beyond 700, the
    > picture's width and height both expand. But when the browser's width is
    > less than 700, the picture does not shrink. Just scroll bars.
    >
    > Thus, I thought that perhaps a JavaScript function might work to reduce
    > the size of the image.


    Ah, I see that it shrinks nicely in Firefox, but not IE 6 :(
    Bob Richardson, Mar 8, 2005
    #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. Jeff S
    Replies:
    1
    Views:
    358
    Scott Allen
    Jan 20, 2004
  2. Leon
    Replies:
    2
    Views:
    3,021
  3. jayapal

    object file size is reduced after build

    jayapal, Dec 18, 2007, in forum: C Programming
    Replies:
    46
    Views:
    913
    Richard Heathfield
    Dec 26, 2007
  4. jayapal

    object file size is reduced after build

    jayapal, Dec 18, 2007, in forum: C Programming
    Replies:
    5
    Views:
    286
    santosh
    Dec 18, 2007
  5. Decrypt

    shrink to at a certain size

    Decrypt, Sep 19, 2008, in forum: HTML
    Replies:
    2
    Views:
    427
    Tim Greer
    Sep 19, 2008
Loading...

Share This Page