簡體   English   中英

上一個學期的第一個孩子的父母分區的最小身高

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

我有一個具有基本標記的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>

Feed的問題是,括號的高度固定為400px(或其他任意數字)。 所以我的問題是:

如何確保將父容器div的min-heights設置為類“ cfg-item”的第一個div。 想法是顯示第一個Facebook feed項的完整輸出,因此不會切斷任何內容。

我有類似的東西:

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

我可能不太清楚您的問題,但是如果您要選擇類.cfg-item的第一個div,請嘗試以下路徑:

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

因此,您將所有.cfg-item div稱為“容器” div,然后選擇第一個。

希望它能對您有所幫助,只要我理解得更好,或者您解釋得更好一點,我就會為您提供更精確的信息。

編輯1:

具體來說,您可以執行以下操作:

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

編輯2:

HTML:

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

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

我沒有檢查,我在工作並且沒有很多時間。 我可以稍后再檢查。

我希望它能對您有所幫助,至少給您一些想法。 祝好運! ;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM