[英]stack images in html page in as many columns as available
Another one of my HTML/CSS/JS hurdles.我的另一个 HTML/CSS/JS 障碍。
I have 12 photos which I need to fit in a page like this:我有 12 张照片需要放在这样的页面中:
This code nails some of it, but doesn't quite cut it: the images fill up all the available space only if they're in 3 columns, any less and they stick to the minimum size of 160px;这段代码指出了其中的一部分,但并没有完全消除它:图像只有在 3 列中才会填满所有可用空间,或者更少,并且它们坚持最小尺寸 160 像素; and zooming the page doesn't work right, at least in Opera:
并且缩放页面不能正常工作,至少在 Opera 中:
img.photoGallery {
min-width: 160px;
max-width: 32%;
float: left;
}
Tables can't do this.表无法做到这一点。 CSS doesn't seem to, either.
CSS 似乎也没有。 I'll probably resort to JavaScript, although I'm reluctant to depend on it.
我可能会求助于 JavaScript,尽管我不愿意依赖它。 So is there a trick which I don't know, and which can help me out?
那么有没有我不知道的技巧可以帮助我?
Instead of "max-width: 32%", what if you put "width: 100%"?如果你输入“width: 100%”而不是“max-width: 32%”呢? If you want an image to fit it's container's width, you should put it's width as 100%.
如果您希望图像适合其容器的宽度,则应将其宽度设置为 100%。 However, I can't visualize your layout properly, so this may not be what you are looking for.
但是,我无法正确可视化您的布局,因此这可能不是您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.