简体   繁体   English

上一个学期的第一个孩子的父母分区的最小身高

[英]Parent Div(s) min height of first child with class

I have a div with basic markup as:- 我有一个具有基本标记的div:-

<div class="jp-container" style="height: 400px;">
<div class="jspContainer" style="height: 400px;">
<div class="class="jspPane">
  <div class="cfg-item"></div>
  <div class="cfg-item"></div>
  <div class="cfg-item"></div>
  <div class="cfg-item"></div>
</div>
</div>
</div>

problem with the feed is that the height of the paren(s) is fixed to 400px (or another arbitrary figure). Feed的问题是,括号的高度固定为400px(或其他任意数字)。 So my question is:- 所以我的问题是:

How can I ensure that the parent container divs min-heights are set to the first div with class "cfg-item". 如何确保将父容器div的min-heights设置为类“ cfg-item”的第一个div。 Idea is to show the full output of the first Facebook feed item so none is cut off. 想法是显示第一个Facebook feed项的完整输出,因此不会切断任何内容。

I have something like:- 我有类似的东西:

<script>
jQuery(document).ready(function($) {
$('.jspContainer .cff-item').first(function(){
$('.jspContainer, .jp-container').css('min-height', $(this).outerHeight());
}); 
});
</script>

I maybe didn't understand well your question, but if you want to select the first div with the class .cfg-item try this path: 我可能不太清楚您的问题,但是如果您要选择类.cfg-item的第一个div,请尝试以下路径:

$(".jspPane").next(".cfg-item");

SO you call the "container" div of all the .cfg-item divs and you select the first one. 因此,您将所有.cfg-item div称为“容器” div,然后选择第一个。

Hope it helped, as soon as I understand better or you explain a little better I try to give you something more precise. 希望它能对您有所帮助,只要我理解得更好,或者您解释得更好一点,我就会为您提供更精确的信息。

EDIT1: 编辑1:

To be more specific you can do this: 具体来说,您可以执行以下操作:

 $("div.jspPane").next("div.cfg-item");

EDIT2: 编辑2:

HTML: HTML:

<div class="jp-container minHeight" style="height: 400px;"> <div class="jspContainer minHeight" style="height: 400px;">

jQuery: jQuery的:

// We declare variables
var containers = $(".minHeight");   //We put both containers in same variable with same class
var firstChild = $(".jspPane").next(".cfg-item").height();  //We get the first child height

containers.css('min-height', firstChild);  //We give the containers the height of the first child

I didn't check this, I am at work and don't have much time. 我没有检查,我在工作并且没有很多时间。 I can check it later. 我可以稍后再检查。

I hope it helped you, and at least gave you some ideas. 我希望它能对您有所帮助,至少给您一些想法。 Good luck! 祝好运! ;) ;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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