jquery - 将父 DIV 高度调整为内部内容(RSS 提要)

标签 jquery html css rss

我正在使用 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/

相关文章:

javascript - iOS 6 上的 Safari 是否缓存 $.ajax 结果?

javascript - 美元用什么。当方法由变量的值给出时

javascript - Jquery 在解析时将巨大的数组拆分为许多新的回调

javascript - 在 Mozilla 中未调用 Div onclick 事件

php - 在 include() 之前使用变量

html - 在手机上看到的带有 mathjax 的博客

css - 页面滚动时在 IE7 上出现问题。文本不正确

html - 如何将 <aside> block 放在 <article> block 下方而不是紧挨着它

html - BootstrapVue : Creating 2 Navbars with Bottom Navbar that Sticks to the Top?

css - 有没有人有适用于大多数手机/设备的移动 CSS 模板的良好资源?