简体   繁体   English

如何随着浏览器宽度/高度的变化动态调整图像网格的大小?

[英]How can I resize an image grid dynamically as the browser width/height changes?

I'm trying to design a page which contains a list of images and on re-size of the browser/window the images should get adjusted in such a way that the images should be in only three rows. 我正在尝试设计一个页面,其中包含图像列表,并且在调整浏览器/窗口的大小时,应以使图像仅在三行中的方式调整图像。 For example initially I have 10 images in a row and as a whole I have total 30 images in three rows. 例如,最初我连续有10张图像,整体上我总共有3行30张图像。 When I re-size the window the images should get adjusted (as the window gets smaller, the grid goes to 7 images in a row and then to 5 images in a row). 当我调整窗口大小时,应该调整图像(随着窗口变小,网格将连续显示7张图像,然后连续显示5张图像)。 And at any point of time I should have only 3 rows. 而且在任何时间点我都应该只有3行。

I have added the below link which is serving same kind of purpose. 我添加了以下链接,该链接用于相同目的。

eg https://www.mozilla.org/en-US/about/?icm=tabz 例如https://www.mozilla.org/en-US/about/?icm=tabz

Any suggestion will be appreciated. 任何建议将不胜感激。

Thanks in Advance. 提前致谢。

That Mozilla page uses Animated Responsive Image Grid, a jquery plugin: 该Mozilla页面使用了Animated Responsive Image Grid,这是一个jquery插件:

http://tympanus.net/codrops/2012/08/02/animated-responsive-image-grid/ http://tympanus.net/codrops/2012/08/02/animated-responsive-image-grid/

You'll want something like 您会想要类似

$(function(){
    $("#the_id_of_your_grid").gridrotator({
        rows:3,
        columns:10,
        w[some number]:{rows:3,columns:7},
        w[some other number]:{rows:3,columns:5}
    })
});

where the two "w[some number]:" are the equivalent of the CSS media query @media (max-width: [some number]px) . 其中两个“ w [some number]:”等效于CSS媒体查询@media (max-width: [some number]px) There's full documentation on the plugin's website 该插件的网站上有完整的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM