[英]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.