Hi
I’ve been experimenting with some code that will open a larger image of the thumbnail. I am sure there are better ways, but I managed to do it, except that the thumbnails no longer stayed side by side.
I cannot figure out your obsession with the “figure element”.
Nevertheless, this works OK and validates…
[code]
Photographic album
figure {
display:inline-block;
vertical-align:top;
margin:10px 1%;
max-width:23%;
}
figure a {
color:#000;
text-decoration:none;
}
figure img {
width:100%;
height:auto;
border:0;
}
A view of the pulpit rock in Norway.
A view of the pulpit rock in Norway.
A view of the pulpit rock in Norway.
A view of the pulpit rock in Norway.
[/code]
My preference though is to use a list...
[code]
Photographic album
ul{
padding:0;
margin:0;
list-style-type:none;
}
li {
display:inline-block;
max-width:23%;
margin:10px 1%;
vertical-align:top;
}
li a {
color:#000;
text-decoration:none;
}
li img {
width:100%;
height:auto;
border:0;
}
Thinking aloud… and wonder if by using the code, I have ion other pages: img-container{} will be the way out. I certainly don’t have this scaling problem in the other pages.
My images are 240x160 and stated so in the htnl
When I look at their properties in the displayed page they are 234x156
a nd when I test the page in GTMetrix it claims they are 194x129
The images are resized to fit the parent div which is 23% ( as coothead said above) so that’s what size they will be. They can’t be bigger than their parent or they would stick out
In fact, I’ve done that already and solved half the problem. The other half may not be a problem as it does not make sense: GTmetrix keeps saying that the images are being resized by the browser to 194 x 129. I wish i could understand where they got those measurements from.
To test I took out. altogether leaving only the inverted commas, 2 of the 4 measurements in the html and surely GTmetrix complained about those stating that they should be included at 234 x 155
Now if you have an answer for that, you’ll get a medal!
I’ve been using GTMetrix for a long time and find it very useful to point out when I have forgotten to include width/height of images and when they are wrong.
Have you used % widths before? Have you made a responsive layout before?
My point is, that irrespective of what actual dimensions GTMetrix are using, anybody visiting your page with a browser width narrower than about 1200px is going to be seeing those images at a scaled-down size. That’s what your code does - it tells the browser to scale the image.
That’s nonsense and in RWD 99% of images are now resized by the browser. It takes little effort for the browser to do that. Otherwise you would need 1280 images for a 1280px monitor if you want to size them all to fit at each pixel
If you are using an image at only a fixed height and width then it makes sense to have that image display at its native size. However if you have a flexible layout that image will vary in size to fit the layout which is perfectly acceptable.