Overlapping/overlaying multiple inline images

后端 未结 2 2012
灰色年华
灰色年华 2020-12-06 06:09

I have a list of images I\'m trying to overlap so that they look similar to this:

My code:

2条回答
  •  [愿得一人]
    2020-12-06 07:07

    I like Temani's better, but if you can't use flex because you have to support IE 9 or earlier, I'll leave this here.

    Note that the text direction is now right to left, so you'll need to reverse the order of your avatars.

    .avatar img {
      border-radius: 50%;
      position: relative;
      left: -5px;
      margin-left: -25px;
      z-index: 1;
    }
    
    .avatars {
      direction: rtl;  /* This is to get the stack with left on top */
      text-align: left;  /* Now need to explitly align left */
      padding-left: 25px;  /* Same value as the negative margin */
    }

提交回复
热议问题