简体   繁体   English

CSS / jQuery图像网格布局

[英]CSS/jQuery image grid layout

I have read many threads about image grid layouts using jQuery or even sole CSS, but mine is a little bit different to what I have read as they are mainly using columns with differing widths. 我已经阅读了许多有关使用jQuery甚至是唯一CSS进行图像网格布局的主题,但是我的阅读内容与我阅读的内容有所不同,因为它们主要使用宽度不同的列。

I am also purposely not pasting any code at this point due to the fact that I have tried various different methods that my code seems no longer 'nice'. 由于我尝试了各种不同的方法,使得我的代码似乎不再“不错”,因此我刻意不粘贴任何代码。

As you can see from this page: http://tinyurl.com/poxn4un - what I am trying to acheive is the images (in Our Work section) laid out how they are now but with the bottom two slotting nicely between the two edge images. 如您在此页面上所看到的: http : //tinyurl.com/poxn4un-我想要实现的是图像(在“我们的工作”部分中)展示了它们现在的状态,但底部两个在两个边缘之间很好地排列了图片。

I have tried masonry with no success and also tried flexbox which is what is it in use at this point. 我尝试了砌体没有成功,还尝试了flexbox,这是目前使用的方法。 Any help would be appreciated as this is something I wish to learn for other projects. 任何帮助将不胜感激,因为这是我希望在其他项目中学习的东西。

Thanks, Adrian 谢谢阿德里安

You could use a flex-box combination layout for this. 您可以为此使用弹性框组合布局。

Here's an example: 这是一个例子:

JSFiddle example JSFiddle示例

And here's the CSS and HTML powering it: 这是支持它的CSS和HTML:

 * { box-sizing: border-box; } .bricks { display: flex; height: 450px; flex-direction: row; } .bricks > * { border: solid 1px #222; } .sidebar { flex: 0 0 220px; background-image: url(https://placehold.it/220x450/075883); } .center-contain { flex: 0 0 402px; font-size: 0; } .center { display: inline-block; background-image: url(https://placehold.it/200x225); border: solid 1px #e5e5e5; height: 225px; } .center.m { width: 200px; } .center.lg { width: 300px; } .center.sm { width: 100px; } 
 <div class='bricks'> <div class='sidebar sidebar-left'></div> <div class='center-contain'> <div class='center sm'></div> <div class='center lg'></div> <div class='center m'></div> <div class='center m'></div> </div> <div class='sidebar sidebar-right'></div> </div> 

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

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