具有绝对固定子代的父容器上的自动高度

具有绝对固定子代的父容器上的自动高度,第1张

具有绝对/固定子代的父容器上的自动高度

当父级div

height:auto
的子级定位为绝对/固定时,则无法使用。

您将需要使用Javascript来实现此目的

jQuery中的一个示例:

var biggestHeight = 0;// Loop through elements children to find & set the biggest height$(".container *").each(function(){ // If this elements height is bigger than the biggestHeight if ($(this).height() > biggestHeight ) {   // Set the biggestHeight to this Height   biggestHeight = $(this).height(); }});// Set the container height$(".container").height(biggestHeight);


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5641240.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存