我正在使用 Google Feed API 将 RSS 提要嵌入到我的 html 网站中。 我尝试使用 jquery 使父 DIV 调整其高度:
function setHeightParent() {
$("#Parent").height($("#feed").height() + 200);
}
这会产生一个高度为 200 像素的父 DIV。 我认为高度是在“feed”div 有任何内容之前计算的,因此没有高度.. 我做错了什么,我怎样才能让它占据最终“feed”div 的高度?
最佳答案
我知道了...
Amir 对延迟的看法是正确的。
这样解决的:
$(document).ready(function() {
function setHeightParent() {
$("#Parent").css("height", $("#feed").height() + 250);
}
setTimeout(setHeightParent, 800)
});
关于jquery - 将父 DIV 高度调整为内部内容(RSS 提要),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29868160/