【问题标题】:Get children height out of parent height让孩子的身高超出父母的身高
【发布时间】:2016-04-18 19:16:39
【问题描述】:

您好,我使用这个插件使所有 div 的高度相等。

https://github.com/Sam152/Javascript-Equal-Height-Responsive-Rows

$('.item-container').responsiveEqualHeightGrid();

我的问题是,我希望父 div 内的子 div 也计算。

例如。我希望前两列底部的所有添加到购物车按钮都相同。他们将获得最高的高度。第一个细节将是子 div,以使添加到购物车按钮向下。有人可以帮我吗?

谢谢

【问题讨论】:

  • 创建一个小提琴,以便我们可以快速帮助您。
  • 一个只有 css 的解决方案想使用绝对和相对位置,
  • @HassanNisarKhan 第一个细节实际上是动态的
  • 是的,我知道,但这没关系。添加到购物车按钮将绝对从底部定位,比如说 10px ..您的等高插件将处理高度(即,使每个div 300px),所以您的添加到购物车按钮将始终位于同一位置(在他的情况下,容器块上方 10px)
  • @HassanNisarKhan 我明白你的意思,但只有图像有高度,其余的都是动态的。

标签: javascript jquery html css


【解决方案1】:

在这个方法里面:responsiveEqualHeightGrid

编写一些可以调整底部子 div 高度的内容,例如:

responsiveEqualHeightGrid(){
    var itemContainerHeightThatYouCalculatedBefore; //code of your method that calculate item-container responsive height
    var imageHeight = $('.item-container img').outerHeight;
    var calculateBottomContainerHeightWithAddButton = itemContainerHeightThatYouCalculatedBefore - imageHeight;

    $('.item-container .bottomContainerWithAddButton').outerHeight = calculateBottomContainerHeightWithAddButton;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-15
    • 1970-01-01
    • 1970-01-01
    • 2020-05-09
    • 2019-10-16
    • 1970-01-01
    相关资源
    最近更新 更多