【发布时间】:2014-01-04 07:48:26
【问题描述】:
我有一个来自truspilot 的小部件,它制作了一个我试图做出响应的 iframe。我已经在 SO 上搜索了几个小时来找到如何做到这一点,但似乎没有解决方案可以响应地调整我的高度和宽度。
这是小部件
<div class="tp_-_box" data-tp-settings="domainId:3660907">
<a href="http://www.trustpilot.com/review/www.longtiestore.com" rel="nofollow" hidden>Long Tie Store Reviews</a>
</div>
<script type="text/javascript">
(function () { var a = "https:" == document.location.protocol ? "https://ssl.trustpilot.com" : "http://s.trustpilot.com", b = document.createElement("script"); b.type = "text/javascript"; b.async = true; b.src = a + "/tpelements/tp_elements_all.js"; var c = document.getElementsByTagName("script")[0]; c.parentNode.insertBefore(b, c) })();
</script>
我的 iframe 宽度仅适用于:
iframe {width:100%}
但 iframe 中有一个元素需要设置为 100% 才能使布局正常工作。
.tp-box {width:100%;}
但我无法对父级 iframe 中的内容进行样式化。所以我尝试添加:
window.onload = function () {
if (parent) {
var oHead = document.getElementsByTagName("head")[0];
var arrStyleSheets = parent.document.getElementsByTagName("style");
for (var i = 0; i < arrStyleSheets.length; i++)
oHead.appendChild(arrStyleSheets[i].cloneNode(true));
}
}
但没有成功。
那么我该怎么做才能使宽度和高度流动?
【问题讨论】:
标签: html iframe responsive-design