Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Stretched Image Problem

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #22993
    iamaw
    Member

    I hate to bother you guys with this, but it’s driving me crazy… Im helping my Dad build a portfolio website… so far so good. I decided to use a simple jQuery image gallery I found on Webdesignerwall.com…. http://www.webdesignerwall.com/demo/jqu … ement.html

    It does exactly what I want it to do, but the only problem is that if the images aren’t all the exact same height they stretch and become distorted when browsing through the gallery. So maybe this is a jQuery problem, not CSS…?

    View this page and try clicking the second or third image in the gallery on the bottom of the page…
    http://garyawinter.com/wordpress/?page_id=16

    You’ll notice that at first the image dimensions get screwed up completely… but if you keep clicking through the gallery they eventually fix themselves and display as they should. Is there anyway to prevent the images from having this problem at all? Please let me know, Im pulling my hair out trying to figure this out and I really dont want to change all the images to be the exact same dimensions as a shortcut to solve this problem.

    Here is the jQuery code (unaltered besides the heading tags, I used exactly what WDW provided):

    Code:

    The markup:

    Code:
    Large image

    And in case it matters, the CSS:

    Code:
    h4 {
    font: bold 190%/100% Arial, Helvetica, sans-serif;
    margin: 0 0 .2em;
    }
    h4 em {
    font: normal 80%/100% Arial, Helvetica, sans-serif;
    color: #999999;
    }

    #largeImg {
    border: solid 1px #ccc;
    width: 496px;
    height: 100%;
    padding: 5px;
    }
    .thumbs img {
    border: solid 1px #ccc;
    width: 75px;
    height: 75px;
    padding: 3px;
    margin:5px 1px 0px 0px;
    float:left;
    }
    .thumbs img:hover {
    border-color: #FF9900;
    }

    #48751
    chazzwick
    Member

    i think if you put the large image in a div with this style:

    Code:
    div.portfolio-img {
    height:xxx px;
    width:yyy px;
    overflow: hidden;
    }

    then set the image to be the same width as its containing div:

    Code:
    div.portfolio-img img {
    width:yyy px;
    }

    then it should keep to your dimensions without stretching the image.

    #48752
    iamaw
    Member

    Hey chazzwick… that wasn’t quite it (unless I did something wrong)… but you got me on the right track!
    I created a new div around the largeImg called largeImgWrapper and gave it these styles:

    Code:
    #largeImgWrapper { }
    #largeImgWrapper img { width:auto; height:auto; }

    Now it works in Firefox perfectly. Try it out.
    Unfortunately it still isn’t working properly in IE. If you try it in IE, you have to click the thumbnail twice for it to adjust to the correct dimensions. Anyone have any idea how to that?

    Thanks again chazzwick!

    #48783
    iamaw
    Member

    Anyone know how the image gallery can be fixed in IE? Sorry for the bump, but I’d appreciate any help I can get…!

    http://garyawinter.com/wordpress/?page_id=16

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.