0

how can I solve this image oversize problem in my simple HTML photogallery with finding images in directory by PHP? I can't solve it and it's not visually good. Can you please help me? Screenshot is

Thanks.

Horizon_Net
  • 5,959
  • 4
  • 31
  • 34
  • What do you mean by "image oversize"? Maybe you should state what is it that you want to achieve instead, e.g. "I want all images to be the same size (200x200)" And how do you want to treat aspect ratios? Always retain aspect ratio? Do you want to show only a crop of the photo if the ratio is off? Do you want to show black bars? white bars? – light Jun 13 '15 at 14:05

3 Answers3

0

Set all of the pictures with the same class, then add an image height to that class and it will set the images to all the same height.

Here is an example that i just made - http://jsfiddle.net/3gd5ooLf/

Im not sure how you are getting the image in PHP so i can't tell you how to set the class without seeing some code.

here's the CSS example:

.height {
    height: 100px;
}
nomistic
  • 2,902
  • 4
  • 20
  • 36
Matt Hammond
  • 372
  • 2
  • 11
0

This may be a good example to you . Refer to stackoverflow old question too. here is the link:link

    .img {
    position: relative;
    float: left;
    width:  100px;
    height: 100px;
    background-position: 50% 50%;
    background-repeat:   no-repeat;
    background-size:     cover;
}

<div class="img" style="background-image:url('http://i.imgur.com/tI5jq2c.jpg');"></div>
Community
  • 1
  • 1
shrestha rohit
  • 2,920
  • 2
  • 13
  • 20
0

In your css file, you could add heigth and width property to adjust the images size.

For example:

img {

  heigth:200px;
  width: auto;

}

will set the heigth to 200px, but will keep the aspect ratio. To have square images, set the width to, for example, 200px

If you prefer, you could set the image to be scrollable when it's too long like so:

img {

  height:200px;
  width:200px;
  overflow: scroll;

}
AdminXVII
  • 1,319
  • 11
  • 22