【问题标题】:Image pile with position absolute具有绝对位置的图像堆
【发布时间】:2022-01-26 09:42:37
【问题描述】:

我创建了一堆图片,您可以点击它们。通过单击顶部图像,它会将 z-index 向后移动图像数量。这些图像需要有一个共享的描述。如果我将 position:absolute 放在它们上面(堆叠它们)。描述也会堆积起来。有没有办法把它们放在图片下面?

.image-pile {
    position: relative;
}

.images img {
    position: absolute;
    width:300px;
}

https://jsfiddle.net/td59pr1h/

【问题讨论】:

    标签: image stack position absolute


    【解决方案1】:

    .image-pile 没有高度,因为内容是绝对定位的。通过在 javascript 中计算高度来修复它。

    var imgheight = $( ".images img" ).innerHeight()
    
    $('.images').css('height', imgheight)
    

    【讨论】:

      猜你喜欢
      • 2021-12-21
      • 2014-12-06
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 2016-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多