+ Reply to Thread
Results 1 to 4 of 4

Thread: Resize picture with css

  1. #1
    Join Date
    May 2007
    Location
    Eauze, France
    Posts
    159
    Thanks
    10
    Thanked 17 Times in 15 Posts

    Default Resize picture with css

    I have an image http://bookholidayrentals.com/Pics/020641.jpg
    which is 320 x 240 pixels

    I want to display it slightly larger by specifing width and height percentages but even 102% gives something way to big.

    It seems that if I specify:
    .pic {
    width:94%;height:94%
    }

    That I get the picture display as I want with properties of 353 x 264 [IE8]pixels.

    Can anyone explain to me why?

    Note: FF & IE8 give results a few picels different : FF: 320px × 232px (scaled to 353px × 256px).

  2. #2
    Join Date
    Apr 2006
    Location
    Amsterdam
    Posts
    342
    Thanks
    19
    Thanked 11 Times in 11 Posts

    Default

    How about just setting the size properties in pixel?

    Code:
    .pic {
    width:353px;
    height:264px;
    }
    Quote Originally Posted by SKILLIT View Post
    I have an image http://bookholidayrentals.com/Pics/020641.jpg
    which is 320 x 240 pixels

    I want to display it slightly larger by specifing width and height percentages but even 102% gives something way to big.

    It seems that if I specify:
    .pic {
    width:94%;height:94%
    }

    That I get the picture display as I want with properties of 353 x 264 [IE8]pixels.

    Can anyone explain to me why?

    Note: FF & IE8 give results a few picels different : FF: 320px × 232px (scaled to 353px × 256px).

  3. #3
    Join Date
    May 2007
    Location
    Eauze, France
    Posts
    159
    Thanks
    10
    Thanked 17 Times in 15 Posts

    Default

    The picture could have different dimentions and even be portrait - so using a percentage should keep the aspect ratio.

    It would appear that the percentage actually applies to the container and not the image so I need to try a few more things.

    Thanks David.

  4. #4
    Join Date
    Mar 2005
    Location
    Isle of Man
    Posts
    1,258
    Thanks
    3
    Thanked 23 Times in 23 Posts

    Default

    Quote Originally Posted by SKILLIT View Post
    The picture could have different dimentions and even be portrait - so using a percentage should keep the aspect ratio.

    It would appear that the percentage actually applies to the container and not the image so I need to try a few more things.

    Thanks David.
    Yep, the CSS percentage will be a percentage of the parent element's width, and nothing to do width the image.

    It's really still JavaScript that you want to use to achieve this, when you can't assume the original image size. Should be pretty easy...

  5. The Following User Says Thank You to nick For This Useful Post:

    RFH Reseller: SKILLIT (12th April 2009)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. CSS Frameworks
    By Si Philp in forum HTML/CSS/JavaScript
    Replies: 1
    Last Post: 28th June 2008, 02:21 PM
  2. CSS help needed
    By schofieldandwhite in forum HTML/CSS/JavaScript
    Replies: 1
    Last Post: 18th November 2006, 05:35 PM
  3. CSS Guide/Tutorial
    By carpeni in forum Garble
    Replies: 7
    Last Post: 28th April 2006, 10:21 PM
  4. IE Tables Ignores CSS
    By JamesU2002 in forum General Technical Support
    Replies: 9
    Last Post: 25th April 2006, 04:53 AM
  5. Open Picture Window Fever Help
    By s80wkr in forum HTML/CSS/JavaScript
    Replies: 2
    Last Post: 21st October 2005, 01:24 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts