简体   繁体   English

将div左上方的一组图像与CSS对齐

[英]Align a set of images at top left of a div with css

I use this code: 我使用以下代码:

.photocontents {
    position: relative;
    display: inline-block;
    padding: 20px;
    margin: 0px;
    width: 100%;
    height: auto;
}
.photo {
    position: relative;
    float: left;
    display: inline;
    padding: 0px;
    margin: 10px;
    width: auto;
    height: auto;
}

to make a photo gallery that has the result of image (a). 制作具有图片(a)结果的相册。

What I want is to align those photos at top too, as image (b) shows. 我想要的是也将这些照片放在顶部,如图(b)所示。 How is that possible? 那怎么可能?

左上对齐

It's not possible with pure CSS. 纯CSS是不可能的。 You have to use some Javascript. 您必须使用一些Javascript。

These jQuery plugins are doing exactly what you're looking for: 这些jQuery插件完全可以满足您的需求:

  1. jQuery Isotope jQuery同位素
  2. jQuery Masonry jQuery砌体

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

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