简体   繁体   中英

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).

What I want is to align those photos at top too, as image (b) shows. How is that possible?

左上对齐

It's not possible with pure CSS. You have to use some Javascript.

These jQuery plugins are doing exactly what you're looking for:

  1. jQuery Isotope
  2. jQuery Masonry

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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