[英]How to add height for content post of wordpress?
您可以使用jQuery來檢測最高的內容,並將所有元素的高度設置為最高的元素。
在這種情況下, #custom_element是我的包含所有帖子的容器。
.content是一個容器,其中包含每個帖子的我的文本,圖像等。
簡短示例:
function resizeContent() {
jQuery('#custom_element').each(function(){
// Select and loop the container element of the elements you want to equalise
var highestBox = 0;
jQuery('.content').css("height","");
// Select and loop the elements you want to equalise
jQuery('.content', this).each(function(){
// If this box is higher than the cached highest then store it
if(jQuery(this).height() > highestBox) {
highestBox = jQuery(this).height();
}
});
// Set the height of all those children to whichever was highest
jQuery('.content',this).height(highestBox);
});
}
//adjust dimensions when loaded
jQuery(window).on('load', function () {
resizeContent();
});
//adjust dimensions when window size gets changed
jQuery( window ).resize(function() {
resizeContent();
});
PHP-示例:
<div id="custom_element">
<div class="content"></div>
<div class="content"></div>
.
.
.
</div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.