简体   繁体   English

CSS / JS:将图块左右对齐

[英]CSS/JS: Align tiles left and top

I'm having thumbnails with always the same image-width , and a possible different image-height. 我的缩略图始终具有相同的图像宽度 ,并且可能具有不同的图像高度。

Now, I want to align them all in order to have no 'gaps' in my thumbnails/tile-overview. 现在,我想将它们全部对齐,以使缩略图/图块概览中没有“空白”。 I'm only floating them left now. 我现在只剩下它们了。 But that gives the result below. 但这给出了以下结果。

Isn't there a JS library available for this? 没有为此提供的JS库吗? (= align tiles with the same width, different height, without any gaps?) (=对齐具有相同宽度,不同高度,没有任何缝隙的瓷砖?)

浮动图片

What you're looking for is a jQuery plugin named Masonry. 您正在寻找的是一个名为Masonry的jQuery插件。 It's known for being a pain in the arse though. 众所周知,这是种痛苦。 Depending on the scale of your application I'd use a CSS3 or flex-box alternative. 根据您应用程序的规模,我会使用CSS3或flex-box替代方案。

jQuery Masonry - http://masonry.desandro.com/ jQuery Masonry- http://masonry.desandro.com/

CSS3 Masonry - http://w3bits.com/css-masonry/ CSS3石工-http: //w3bits.com/css-masonry/

Flex-Box Masonry - http://thenewcode.com/844/Easy-Masonry-Layout-With-Flexbox Flex-Box砌体-http: //thenewcode.com/844/Easy-Masonry-Layout-With-Flexbox

Hope these links help. 希望这些链接能对您有所帮助。 :) :)

The still not so good column can maybe help you.. Can i use column? 仍然不是很好的专栏也许可以为您提供帮助。 我可以使用专栏吗?

 div.wrapper { -webkit-columns: 300px 2; -moz-columns: 300px 2; columns: 300px 2; -webkit-column-rule: 1px dotted rgb(0, 0, 0); -moz-column-rule: 1px dotted rgb(0, 0, 0); column-rule: 1px dotted rgb(0, 0, 0); text-align: center; } 
 <div class="wrapper"> <img src="http://lorempixel.com/image_output/nature-hc-300-450-2.jpg"> <img src="http://lorempixel.com/image_output/people-hc-300-601-10.jpg"> <img src="http://lorempixel.com/image_output/nature-hc-300-306-10.jpg"> <img src="http://lorempixel.com/image_output/abstract-qc-300-148-2.jpg"> <img src="http://lorempixel.com/image_output/cats-hc-300-627-4.jpg"> <img src="http://lorempixel.com/image_output/technics-hc-300-460-8.jpg"> </div> 

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

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